#include <iostream>#include <fstream>using namespace std;class Student {public:int age;string name;};int main() {ofstream ofs("text.txt", ios::out | ios::binary);//ofs.open("text.txt", ios::out | ios::binary)//写文件Student stu;stu.age = 18;stu.name = "王二狗";ofs.write((const char*)&stu, sizeof(Student));return 0;}
