#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int main()
{
string name;
int age;
ofstream outfile;
outfile.open("user1.txt",ios::out | ios::trunc | ios::binary);
while (1)
{
cout << "请用户输入姓名" << endl;
cin >> name;
if (cin.eof())
{
break;
}
outfile << name << endl;
cout << "请用户输入年龄" << endl;
cin >> age;
outfile.write((char*)&age, sizeof(age));
}
outfile.close();
system("pause");
return 0;
}
最后
以上就是繁荣火龙果最近收集整理的关于C++使用文件流写二进制文件的全部内容,更多相关C++使用文件流写二进制文件内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复