Integer Output Scanning

Defines macros for converting integer types to formatted text.

The inttypes.h header file defines macros that expand to a literal character string that forms a conversion specifier suitable for use with formatted output functions.

The table below lists the macros that expand to conversion specifiers for output.
Table 1. Integer Conversion Specifiers for Output
Type Format Macro
int8_t decimal PRId8 or PRIi8
int16_t decimal PRId16 or PRIi16
int32_t decimal PRId32 or PRIi32
int64_t decimal PRId64 or PRIi64
int_least8_t decimal PRIdLEAST8 or PRIiLEAST8
int_least16_t decimal PRIdLEAST16 or PRIiLEAST16
int_least32_t decimal PRIdLEAST32 or PRIiLEAST32
int_least64_t decimal PRIdLEAST64 or PRIiLEAST64
int_fast8_t decimal PRIdFAST8 or PRIiFAST8
int_fast16_t decimal PRIdFAST16 or PRIiFAST16
int_fast32_t decimal PRIdFAST32 or PRIiFAST32
int_fast64_t decimal PRIdFAST64 or PRIiFAST64
intmax_t decimal PRIdMAX or PRIiMAX
intptr_t decimal PRIdPTR or PRIiPTR
int8_t unsigned octal PRIo8
int16_t unsigned octal PRIo16
int32_t unsigned octal PRIo32
int64_t unsigned octal PRIo64
int_least8_t unsigned octal PRIoLEAST8
int_least16_t unsigned octal PRIoLEAST16
int_least32_t unsigned octal PRIoLEAST32
int_least64_t unsigned octal PRIoLEAST64
int_fast8_t unsigned octal PRIoFAST8
int_fast16_t unsigned octal PRIoFAST16
int_fast32_t unsigned octal PRIoFAST32
int_fast64_t unsigned octal PRIoFAST64
intmax_t unsigned octal PRIoMAX
intptr_t unsigned octal PRIoPTR
int8_t unsigned decimal PRIu8
int16_t unsigned decimal PRIu16
int32_t unsigned decimal PRIu32
int64_t unsigned decimal PRIu64
int_least8_t unsigned decimal PRIuLEAST8
int_least16_t unsigned decimal PRIuLEAST16
int_least32_t unsigned decimal PRIuLEAST32
int_least64_t unsigned decimal PRIuLEAST64
int_fast8_t unsigned decimal PRIuFAST8
int_fast16_t unsigned decimal PRIuFAST16
int_fast32_t unsigned decimal PRIuFAST32
int_fast64_t unsigned decimal PRIuFAST64
intmax_t unsigned decimal PRIuMAX
intptr_t unsigned decimal PRIuPTR
int8_t unsigned hexadecimal PRIx8
int16_t unsigned hexadecimal PRIx16
int32_t unsigned hexadecimal PRIx32
int64_t unsigned hexadecimal PRIx64
int_least8_t unsigned hexadecimal PRIxLEAST8
int_least16_t unsigned hexadecimal PRIxLEAST16
int_least32_t unsigned hexadecimal PRIxLEAST32
int_least64_t unsigned hexadecimal PRIxLEAST64
int_fast8_t unsigned hexadecimal PRIxFAST8
int_fast16_t unsigned hexadecimal PRIxFAST16
int_fast32_t unsigned hexadecimal PRIxFAST32
int_fast64_t unsigned hexadecimal PRIxFAST64
intmax_t unsigned hexadecimal PRIxMAX
intptr_t unsigned hexadecimal PRIxPTR
int8_t unsigned hexadecimal with uppercase letters PRIX8
int16_t unsigned hexadecimal with uppercase letters PRIX16
int32_t unsigned hexadecimal with uppercase letters PRIX32
int64_t unsigned hexadecimal with uppercase letters PRIX64
int_least8_t unsigned hexadecimal with uppercase letters PRIXLEAST8
int_least16_t unsigned hexadecimal with uppercase letters PRIXLEAST16
int_least32_t unsigned hexadecimal with uppercase letters PRIXLEAST32
int_least64_t unsigned hexadecimal with uppercase letters PRIXLEAST64
int_fast8_t unsigned hexadecimal with uppercase letters PRIXFAST8
int_fast16_t unsigned hexadecimal with uppercase letters PRIXFAST16
int_fast32_t unsigned hexadecimal with uppercase letters PRIXFAST32
int_fast64_t unsigned hexadecimal with uppercase letters PRIXFAST64
intmax_t unsigned hexadecimal with uppercase letters PRIXMAX
intptr_t unsigned hexadecimal with uppercase letters PRIXPTR
Listing: Example of Integer Output

#include <stdio.h> 
#include <inttypes.h> 
int main(void) 
{ 
intmax_t im = 175812759L; 
printf("%" PRId8 "\n", 63); 
printf("%" PRIxMAX, im); 
return 0; 
} 
Output: 
63 
0xa7ab097