C program yielding different results on different machines despite using the same fixed length data types

It seems you might get this problem in case you are using a Windows compiler which uses Microsoft’s non-compliant CRT (non)standard library. That is: Visual Studio or Mingw64/gcc.

I can reproduce it on Mingw/gcc. It’s a well-known problem that the Microsoft CRT is broken and for example doesn’t support various format specifiers introduced in C99. It would seem that the problem lies in scanf reading with the wrong format specifier, because when compiling with all warnings enabled, I get:

warning: unknown conversion type character ‘h’ in format [-Wformat=]

%hh being what sits underneath the hood of SCNu8 but the compiler only reads as far as %h and stops there. The scanf call actually fails.

You can uncrap the CRT lib at least in Mingw by using the following:

#define __USE_MINGW_ANSI_STDIO 1
#include <stdio.h>

When I added the above to your code, I get The 0th bit of 1 is: 1.
Without the above patch it I get The 0th bit of 0 is: 0

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)