The following code does what the OP wants:
#include <iostream> #include <fstream> using namespace std; int main ( int argc, char ** argv ) { cout << argv[1] << endl; ofstream outfile; outfile.open("testzzzzzzz.txt"); if(outfile.is_open()) { outfile << "Testzzzzz"; outfile.close(); cout << "wrote file"<< endl; } else cout << "Unable to open file"; string s; getline( cin, s ); return 0; }
It allows you to drag and drop, but does not use the name of the dropped file in the opened file. When you drop a file into it, you get a message
"wrote file"
Unfortunately, at the moment I have no idea where he wrote the file - not in the current directory, definitely. Just do a search ...
Edit:. He creates it in the Documents and Settings directory. Therefore, to put it in the current directory, you probably need to explicitly specify it as "./", but I did not check this - I leave it as an exercise for the reader :-)
anon
source share