i gt a struct with 2 integer, i want to store them in a binary file and read it again... here is my code...
static const char *ADMIN_FILE = "admin.bin";
struct pw {
int a;
int b; };
void main(){
pw* p = new pw();
pw* q = new pw();
std::ofstream fout(ADMIN_FILE, ios_base::out | ios_base::binary | ios_base::trunc);
std::ifstream fin(ADMIN_FILE, ios_base::in | ios_base::binary);
p->a=123;
p->b=321;
fout.write((const char*)p, sizeof(pw));
fin.read((char*)q, sizeof(pw));
fin.close();
cout<< q->a << endl;}
my output is 0. anyone can tell me what is the problem?