#include<iostream>
#include<string>
#include<fstream>//头文件包含
using namespace std;
//二进制文件 写文件
class person
{
public:
char m_Name[64]; //姓名
int m_Age; //年龄
};
void test01()
{
//1、包含头文件
//2、创建流对象
ofstream ofs("person.txt", ios::out | ios::binary);
//3、打开文件
//ofs.open("person.txt",ios::out |ios::binary)
//4、写文件
person p = { "张三",18 };
ofs.write((const char*)&p, sizeof(person));
//5、关闭文件
ofs.close();
}
int main()
{
test01();
system("pause");//按任意键继续
return 0;//关闭程序
}