char* docdir = getenv("docdir");
if(docdir) // make sure it's not null. It will be null if the environment variable is not found
std::string path = docdir;
path += "/test.txt";
FILE* file = fopen( path.c_str(), "w");
Although in testing this... it doesn't look like "docdir" is an environment variable (at least not on my box). Where did you get that from?
I'm not sure which envionment var has the location of the documents folder. I'd have to look it up and I'm too lazy to do that right now.
EDIT: ok I'm an idiot. docdir was purely conceptual.
Sorry. =P You can probably disregard most of what I said above.
In windows XP this will return something like "C:\Documents and Settings\All Users\Documents", in windows 7 thgis will return something like "C:\Users\Public\Documents". There is no need to check windows version first.