【发布时间】:2016-08-06 06:05:33
【问题描述】:
我一直在努力保存到文件,这就是结果。唯一的问题是空格后的任何内容都会被忽略,(如果您输入“john smith”)它会打印 (“最后一个使用这个文件的人是:john”)我正在使用带有 GNU GCC 编译器的代码块。代码如下:
#include <iostream>
#include <cstdlib>
#include <fstream>
using namespace std;
int main()
{
string name;
ofstream saveData;
ifstream Data;
Data.open("Info.data", ios::binary);
Data >> name;
Data.close();
cout << "The last person to use the file was " << name << endl;
cout << "What is your name?" << endl;
cin >> name;
saveData.open("Info.data", ios::binary);
saveData << name;
cout << name << endl;
system("PAUSE");
saveData.close();
return 0;
}
谢谢
【问题讨论】:
标签: c++