Macros for specifying the printf and scanf format
specifiers are also provided in <inttypes.h> . Essentially,
these macros prepend the format specifier with an l or ll to specify the argument as a
given the number of bits in the argument, which is built into the name of the macro.
Macros for printf(3C) format specifiers exist for printing 8-bit, 16-bit, 32-bit, and 64-bit integers, the smallest integer types, and the biggest integer types, in decimal, octal, unsigned, and hexadecimal. For example, printing a 64–bit integer in hexadecimal notation:
int64_t i; printf("i =%" PRIx64 "\n", i);
Similarly, there are macros for scanf(3C) format specifiers for reading 8-bit, 16-bit, 32-bit, and 64-bit integers and the biggest integer type in decimal, octal, unsigned, and hexadecimal. For example, reading an unsigned 64–bit decimal integer:
uint64_t u; scanf("%" SCNu64 "\n", &u);
Do not use these macros indiscriminately. They are best used in conjunction with the fixed-width types. Refer to the section Fixed-Width Integer Types for more details.