【发布时间】:2011-08-23 18:56:20
【问题描述】:
我想连接一个包含路径和文件名的文件名。然后我可以打开并编写它。但我没有这样做。
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做什么?!
标签: c++ string concatenation