You are probably opening the file in text mode. In this mode, 0x0A is seen as a 'new line' so a 0x0D 0x0A ( CR LF ) is generated to start a new line. Look at help for '_fmode' or for 'fopen'. You'll need to change to binary mode.