Environment variables aren't expanded in string literals. You need to call something like getenv to get the value:
#include <cstdlib>
//...
const char *appdata = std::getenv ( "APPDATA" );
if ( appdata != 0 ) {
std::string path = appdata;
path += "\\Folder\\file.txt";
std::ifstream file ( path.c_str() );
//...
}
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
>Lately it's been mostly Java.
I'm sorry. ;)
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401