I use this
#include <fstream>
#include <iostream>
using namespace std;
class Student
{
public:
char FullName[40];
char CompleteAddress[120];
char Gender;
double Age;
bool LivesInASingleParentHome;
};
int main()
{
Student one;
strcpy(one.FullName, "Ernestine Waller");
strcpy(one.CompleteAddress, "824 Larson Drv, Silver Spring, MD 20910");
one.Gender = 'F';
one.Age = 16.50;
one.LivesInASingleParentHome = true;
ofstream ofs("fifthgrade.ros", ios::binary);
ofs.write((char *)&one, sizeof(one));
return 0;
}
and output in the file is
"Ernestine Waller ( ภ( ุ" ”์รu ( 824 Larson Drv, Silver Spring, MD 20910 ๓’ ุ" “๑รu ์" fฃรu๐แฬu," โ์รu ฮ1ฤuง1ฤu`ด0] F๘@ " €0@$ลuไzึ("
it seem string data can be see from the file but I want it can't read. how can I solve it?