I have a prog in c:\prog\prog.exe
whats the easiest way to get it to read c:\prog\prog.ini without actually telling it the path.
so that if i moved both files to c:\prog2\
the exe would read c:\prog2\prog.ini
thanks
I have a prog in c:\prog\prog.exe
whats the easiest way to get it to read c:\prog\prog.ini without actually telling it the path.
so that if i moved both files to c:\prog2\
the exe would read c:\prog2\prog.ini
thanks
I belive if you this,
the program will open the file in that directory the program is running from.Code:fstream file("prog.ini", ios::in);
Note however that this doesn't work if you use the PATH variable or explicit path specification to launch your app.
Great, now I'm making you nervous
Suffice to say, directory support in the standard C++ library is bad.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
You can always retrieve the path to the program with the GetModuleFileName() API call, if you need to.
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
You can also retrieve the path + filename like this,
It's just a matter of removing the filename and you have the path to where the program is located.Code:#include <iostream> #include <stdlib.h> main(int argc, char * argv[]) { cout << " *argv << endl; system("PAUSE"); return 0; }
But even so, I believe you'll run into problems if your program's directory is in the PATH variable, and you simply invoked it with "prog-name".Originally posted by laasunde
You can also retrieve the path + filename like this,
It's just a matter of removing the filename and you have the path to where the program is located.Code:#include <iostream> #include <cstdlib> main(int argc, char * argv[]) { std::cout << " *argv << std::endl; std::system("PAUSE"); return 0; }
The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.
Zach L. : Never heard of that but then again Im new to c++ programming. Thanks for the info