Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drag & Drop input weirdness

Status
Not open for further replies.

js73

Programmer
Jun 14, 2004
1
US
Consider the following simple test program which copies a text file specified on the command line to out.txt...
Code:
#include <iostream>
#include <fstream>
using namespace std;

int main(int argc,char *argv[]) {
	ofstream out;
	ifstream in;
	char buffer[50000];
	out.open("out.txt");
	in.open(argv[1]);
	while (in.getline(buffer,50000)) {
		out<<buffer<<endl;
	}
	in.close();
	out.close();
}

This works as expected but I was curious as to how Windows would handle it if I dragged the text file and dropped it on top of the executable icon. It appears to work as I expected...dragging in.txt onto the test.exe icon passes

test.exe in.txt

However, even though it opens in.txt and reads through it properly, out.txt is not created. Can anybody tell me why this is?
 
I suppose it is created, but in sime windows or user default directory. Try to use there an absolute path:

out.open("xxx:\\path...\\out.txt");


Ion Filipski
1c.bmp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top