cout << "Press ENTER to exit..." << endl;
getchar();
return 0;
}
-------------------------------
It works fine, except the new file that is written to ("testing.txt") is created in my Dev-C++ directory (where I installed the actual Dev-C++ application) - instead in my current working directory (where the program's .exe file is).
This is a huge problem for me, as I have wrtten a much larger program which does exactly the same thing.
Is there a setting in Dev-C++ that I need to change?
Please help - this is very important to me.
CHEERS - ANIA
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
you could get the command line which was used to launched your program ; there's the filename and directory in it : it is the first argument of your main function ; you just have to declare
int main( int argc, char * argv[] )
and then locate the position of the last '\' in argv[0] ; all the stuff before it is your path.
Petit_PimoOosE
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have written this program:
------------------------------
#include <fstream>
#include <iostream>
#include <stdio.h>
int main()
{
ofstream SaveFile("testing.txt");
SaveFile << "Hello World, testing file writing";
SaveFile.close();
cout << "Press ENTER to exit..." << endl;
getchar();
return 0;
}
-------------------------------
It works fine, except the new file that is written to ("testing.txt") is created in my Dev-C++ directory (where I installed the actual Dev-C++ application) - instead in my current working directory (where the program's .exe file is).
This is a huge problem for me, as I have wrtten a much larger program which does exactly the same thing.
Is there a setting in Dev-C++ that I need to change?
Please help - this is very important to me.
CHEERS - ANIA
you could get the command line which was used to launched your program ; there's the filename and directory in it : it is the first argument of your main function ; you just have to declare
int main( int argc, char * argv[] )
and then locate the position of the last '\' in argv[0] ; all the stuff before it is your path.
Petit_PimoOosE