Write and read class objects in binary file

Jan 11, 2013 at 4:29pm
if i have 2 variables for which values are given by the user,then,does the information get stored into the file in the name of the variable,or just like packs of information.....if the former is true,how to extract the information of a particular variable alone from the whole file?
Jan 11, 2013 at 4:44pm
Packs of information by the size of the variable.

You will need to know the offset into the file that the data is stored. The offset is the number of bytes that precedes the information.

So:

char s;
char y;
char t;
int Amount;

You want Amount, so the offset is 3 bytes, since a char is one byte.
Jan 11, 2013 at 5:54pm
So,i need to move the file pointer by 3 bytes to access the Amount?
Jan 12, 2013 at 5:25am
Yes.
Jan 12, 2013 at 12:12pm
how to use this pointer in accssing file?
Topic archived. No new replies allowed.