#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int main()
{
string name;
int age;
ofstream outfile;
outfile.open("user1.txt");
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++使用文件流写2进制文件
最新推荐文章于 2024-05-16 10:40:33 发布