#include<iostream>
#include<string>
#include<Windows.h>
#include<fstream>
#include<sstream>
using namespace std;
int main()
{
string name;
int age;
ofstream outfile;
outfile.open("user2.txt");
while (1)
{
cout << "请输入姓名" << endl;
cin >> name;
if (cin.eof())
{
break;
}
cout << "请输入年龄" << endl;
cin >> age;
stringstream s;
s << "姓名" << name << "\t\t\t年龄" << age << endl;
outfile << s.str();
}
outfile.close();
system("pause");
return 0;
}
C++按指定格式写文件
最新推荐文章于 2023-01-10 01:14:16 发布