【发布时间】:2014-12-09 04:08:51
【问题描述】:
有人可以告诉我为什么以下方法不起作用吗?
#include <fstream.h>
#include <iostream.h>
std::string data, newtitle, body;
ofstream outfile;
int main()
{
cout << "enter body of note: ";
cin >> body;
cout << "enter title of note: ";
cin >> newtitle;
data = newtitle + ".dat";
outfile.open(data, ios::out);
outfile << body << endl;
outfile.close();
system("pause");
return 0;
}
问题似乎源于尝试结合 newtitle 和 .dat
谢谢
【问题讨论】:
标签: c++ string file-io ofstream