40*char is not a permitted fwrite precision .
The precision option is not intended to give information about how many elements are being written: instead it gives information about how each input element is to be represented as output. The number is determined by the size of the variable .
If you need to pad then fwrite the pad values yourself .
for example .
It is not possible to fwrite two different datatypes in one call. (However memory mapping routines can input or output entire structure at a time .)