You should overload << operator and let the structure serialise itself. That way if you use different compiler/architecture, you don't have to worry about how the structure is formed in memory.