Hi all. i am writing a simple log in program and i would like to have a class for users that stores the user name and the password as strings. after i have a user created i would like to output the class with the ios::binary flag set and store them in a file user.dat. in know i can the following code to store the class.
User temp("nathan", "password");
ofstream fout("user.dat", ios::binary);
fout.write((char*) &temp, sizeof(temp));
fout.close();
my main concern though is how would i get it back. I'm not sure what i should use for the sizeof() operator when i read from the file.
User temp;
ifstream fin("user.dat", ios::binary);
fin.read((char*) &temp, sizeof( ? ));
fin.close();
any help would be greatly appreciated.