#include<iostream>
#include<string>
#include<fstream>
using namespace std;
int main()
{
string name;
int age;
ifstream infile;
infile.open("user1.txt", ios::in | ios::binary);
while (1)
{
infile >> name;
if (infile.eof())
{
break;
}
cout << name << endl;
char tmp;
infile.read(&tmp, sizeof(tmp));
infile.read((char*)&age, sizeof(age));
cout << age << endl;
}
infile.close();
system("pause");
return 0;
}
C++用文件流读二进制文件
最新推荐文章于 2023-06-09 14:57:37 发布