You're probably better of writing a text file, and putting each string on a separate line. Then you can use getline() to read in the string:
Code:
int size;
std::string name;
in >> size;
getline(in, name)
Or you could delimit the string from other data written to the file with a comma, and use:
Code:
int size;
std::string name;
in >> size;
getline(in, name, ',')
If you're going to use write() and read() with a binary file, then you must read exactly the number of characters written, which your example isn't. Well actually it is, but what you should use instead of sizeof(name) is name.length(). That should work for a binary file.