#include<iostream>
#include<fstream>
using namespace std;
class Person {
public:
char m_Name[64];
int m_Age;
};
void test01() {
// 创建流对象
ifstream ifs;
// 打开文件
ifs.open("person.txt", ios::in | ios::binary);
// 判断文件是否打开成功
if (!ifs.is_open()) {
cout << "File does not exist. " << endl;
}
// 读文件
Person p;
ifs.read((char*)&p, sizeof(Person));
cout << "Name: " << p.m_Name << endl;
cout << "Age: " << p.m_Age << endl;
// 关闭文件
ifs.close();
}
int main() {
test01();
while(cin.get()!=EOF);
return 0;
}