You can setup binary mode in this way, for example.
int result;
// Set "stdout" to have binary mode:
result = _setmode( _fileno( stdout ), _O_BINARY );
if( result == -1 )
perror( "can't set binary mode for stdout" );
else
printf( "stdout mode is binary now" );