Trying to store an int in binary mode using fprintf() but no matter which mode I specify in fopen() it is writing int value only in text format. On the other hand when i use fwrite in place of fprintf it stores the int in binary format. So can we use fprintf in binary mode?
#include <stdio.h>
int main()
{
FILE *fp;
fp = fopen("abc.bin", "wb");
int num = 69;
fprintf(fp, "%d", num);
fclose(fp);
return 0;
}
Also if we talk about other I/O functions which of them will work perfectly with binary mode? Is there anything officially documented about such behaviors ?
I am working on windows platform under mingw.