How should I write a struct to a file in C?
I'm trying to write a struct to a binary file. I want my code to be cross platform, so I'm not sure about just writing the whole struct with a fwrite. If I did this, then the size of the struct will vary depending on the size of the primitive types for each platform(in platform A, an int won't have the same size as in platform B. So the struct won't be the same size either, and the file will end up being different). But I know nothing about this, so should I write each member of the struct individually, serialize the struct (how can I do this?) , or just write the struct whit a fwrite?