Hello all, my name is alfredo, and I am 13 years old. I just started learning c++ about 2 weeks ago, and I am having a problem that's really giving me a headache. I am trying to code a project that will contain 2 files, file1 and file2. When file1 is opened I want file2 to be copied to a specific directory,we can use C:\randomdir for this example, but when my app will be downloaded I don't know where the user is going to download it to. So doing what i had originally done, system("copy C:\downloads\file2 C:\randomdir'); will be pointless, since I don't know if they will download it to C:\downloads or C:\documents or even E:\ files, :( so I am really lost on what to do next, and any help will be much appreciated.

, Alfredo

p.s I have already googled, and searched through daniweb, thank you.

You can find out where the exe is with command line arguments.

#include <iostream>

using namespace std;

int main( int argc, char *argv[] ) {
  cout<< argv[0] <<endl;
  return 0;

Once you have that string, you can trim off the filename and then have a path for storing the files. :)

commented: cool solution +6