我想連接一個包含路徑和文件名的文件名。然後我可以打開並寫下它。但我沒有這樣做。C++中的字符串連接問題
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 '爲?! – 2011-05-31 09:18:26