Consider the following simple test program which copies a text file specified on the command line to out.txt...
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?
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?