How to write binary data to file in C without implementation-defined behavior?
stackoverflow.com