I find trying to lay out data files with the C++ IOStream stuff to be like pulling teeth. Good old fashioned unix read() and write() is much less painful, especially for binary formats. For text formats printf()/scanf() are king. But that's just me.
I'm sure that IOStream has a mode for sending and reading raw bytes. Use that.
I'm sure that IOStream has a mode for sending and reading raw bytes. Use that.