我想将包含路径和文件名的文件名连接起来,然后打开并写入它。但是我没有成功。
char * pPath;
pPath = getenv ("MyAPP");
if (pPath!=NULL)
//printf ("The current path is: %s",pPath); // pPath = D:/temp
string str = "test.txt";
char *buf = new char[strlen(str)];
strcpy(buf,str);
fullName = ?? // how can I get D:/temp/test.txt
ofstream outfile;
outfile.open(fullName);
outfile << "hello world" << std::endl;
outfile.close();
char
缓冲区和strcpy
函数?! - Lightness Races in Orbit