Hello,
First of all, I apologize if this question has been answered before, but I browsed through hundreds of posts, and couldn't find anything thus far.
I have a program in a specified path, d:\ashiq\c++\game. All of my .cpp files are in there, as well as some plain text files I wish to input during the course of my program.
However, I find that there is no way to open a file (for input) without putting in SOME sort of path. By default, it will check my compiler path, which is NOT what I want--I want it to use the program path. Is there a way to do this, other then manually putting in the path? Here's my IO code.
Code:
int showIntro()
{
ifstream logoStream("intro.txt");
if (!logoStream)
{
cout << "File did not open!";
} else {
string line= "";
getline(logoStream, line);
while (line != "")
{
cout << line << "\n";
getline(logoStream, line);
}
}
logoStream.close();
return 0;
}
Is it possible to get the program .exe file path, and to use relative paths? as in /data/art/temp.jpg as opposed to putting the entire path?
Cheers,
--Ashiq