How can I read and write a structure to and from a file?
I'm trying to write a structure to a file, and read that structure in again, possibly with different padding, byte alignment, edianness, and platforms.
fread() and fwrite() don't work when writing the whole structure. Would they work when writing each member of the structure separately?
How could I write a short to a file? Would this work? Would it work only for unsigned shorts?
Can every possible value of a short be written in that way? eg, even ones that would write a '\n' to the file?
Is fwrite()ing a char okay? Even with different edians?