I am reading from files and I want them to be stored in the same location as the program's .ccp file. Since this could change based on where the user puts the application folder, I'm doing the following code to get this to work in Visual C++.
However, I want to add a file name to the end of dir. I have tried putting dir into a stringstream and regular string but no luck yet.
how do I check to see if the file exists? I do NOT want to edit the file. It's being loaded into a font class, I just want to verify it exists in the project folder.
So far (working)...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include <iostream>
#include <sstream>
#include <string>
#include <direct.h>
usingnamespace std;
int main()
{
char * dir = getcwd(NULL, 0);
stringstream s;
s << dir << "\\arial.ttf";
cout << s.str();
//Checks to see if s.str() is a valid path name??
system("pause");
return 0;
}