12345678910111213141516171819202122232425262728293031
struct abc { char name[100]; int a; }; int main() { ofstream file; file.open("text.dat", ios::out | ios::binary); abc x; x.a = 2; cout<<"Enter name "; cin>>x.name; file.write((char*)&x,sizeof(struct abc)); file.close(); getch(); return 0; }