Hi. Suppose I write a string object to a file with
file.write(reinterpret_cast <char*> &myObject, sizeof(myObject) );
Now, I can read it with
file.read(reinterpret_cast <char*> &myObject, sizeof(myObject) );
Now my question is, when I write the file, the size will be determined by the length of the string in the object. But when reading it, how does the compiler know how many bytes to read from the file? Shouldn't the size of each object be different.