Presuming there are no pointers in the struct, there are two issues:

1) The size of types such as int, which can vary. If you want to make sure the struct is portable, you need to use fixed size types such as int32_t, that are guaranteed to be the same size everywhere.

2) Compiler padding: it generally adds a few bytes to the struct if it is not an even multiple of (eg.) 4 or 8 bytes (and possibly with regard to individual fields). That padding can, I think, be in between fields, and another compiler on another computer could do it differently. You want to make sure there is no padding at all, this way the sizeof() is exactly the same as the total of all fields. There is no standard way to do that, but all compilers (I think) have a way of doing it. Eg, for gcc:

Code:
#pragma pack(1)
struct whatever {
I believe that is applied per field, but as long as you use 1 as the argument it won't matter.

Structure-Packing Pragmas - Using the GNU Compiler Collection (GCC)