If the processor is 64 bits and we wanna use 32 integers to print/read them, we can use inttypes.h library to explicitly tells the processor which length we want to use.
#include <inttypes.h> uint8_t 8bit_int; int32_t 32bit_int; printf("Hexadecimal format %" PRIx8 "\n"); printf("Integer format %" PRIi8 "\n"); printf("Hexadecimal format %" PRIx32 "\n"); printf("Integer format %" PRIi32 "\n");
First three letters:
PRI for printf format
SCN for scanf format (Not shown in the example, but it is used in a similar way witch scanf())
Fourth letter:
x for hexadecimal formatting
u for unsigned formatting
o for octal formatting
i for integer formatting
d for decimal formatting