6.7.3 Print Format Macros for Unsigned Integers
Placeholder macros that can be used with the printf
family of functions
when printing unsigned integer values.
Include
<inttypes.h>
Remarks
The macros in following table expand to character string literals representing
placeholders that can be used with the printf
family of functions when
printing unsigned integer values.
Macro Name | Description |
---|---|
PRIo8 | Octal placeholder string for an unsigned 8-bit
integer type (uint8_t ). |
PRIo16 | Octal placeholder string for an unsigned 16-bit
integer type (uint16_t ). |
PRIo32 | Octal placeholder string for an unsigned 32-bit
integer type (uint32_t ). |
PRIo64 | Octal placeholder string for an unsigned 64-bit
integer type (uint64_t ), where supported (see Attention
note). |
PRIu8 | Unsigned decimal placeholder string for an
unsigned 8-bit integer type (uint8_t ). |
PRIu16 | Unsigned decimal placeholder string for an
unsigned 16-bit integer type (uint16_t ). |
PRIu32 | Unsigned decinmal placeholder string for an
unsigned 32-bit integer type (uint32_t ). |
PRIu64 | Unsigned decimal placeholder string for an
unsigned 64-bit integer type (uint64_t ), where
supported (see Attention note). |
PRIx8 /
PRIX8 | Hexadecimal placeholder string for an unsigned
8-bit integer type (uint8_t ). |
PRIx16 /
PRIX16 | Hexadecimal placeholder string for an unsigned
16-bit integer type (uint16_t ). |
PRIx32 /
PRIX32 | Hexadecimal placeholder string for an unsigned
32-bit integer type (uint32_t ). |
PRIx64 /
PRIX64 | Hexadecimal placeholder string for an unsigned
64-bit integer type (uint64_t ), where supported (see
Attention note). |
PRIoFAST8 | Octal placeholder string for the fastest
unsigned integer type with a width of at least 8 bits
(uint_fast8_t ). |
PRIoFAST16 | Octal placeholder string for the fastest
unsigned integer type with a width of at least 16 bits
(uint_fast16_t ). |
PRIoFAST32 | Octal placeholder string for the fastest
unsigned integer type with a width of at least 32 bits
(uint_fast32_t ). |
PRIoFAST64 | Octal placeholder string for the fastest
unsigned integer type with a width of at least 64 bits
(uint_fast64_t ), where supported (see Attention
note). |
PRIuFAST8 | Unsigned decimal placeholder string for the
fastest unsigned integer type with a width of at least 8 bits
(uint_fast8_t ). |
PRIuFAST16 | Unsigned decimal placeholder string for the
fastest unsigned integer type with a width of at least 16 bits
(uint_fast16_t ). |
PRIuFAST32 | Unsigned decimal placeholder string for the
fastest unsigned integer type with a width of at least 32 bits
(uint_fast32_t ). |
PRIuFAST64 | Unsigned decimal placeholder string for the
fastest unsigned integer type with a width of at least 64 bits
(uint_fast64_t ), where supported (see Attention
note). |
PRIxFAST8 /PRIXFAST8 | Hexadecimal placeholder string for the fastest
unsigned integer type with a width of at least 8 bits
(uint_fast8_t ). |
PRIxFAST16 /PRIXFAST16 | Hexadecimal placeholder string for the fastest
unsigned integer type with a width of at least 16 bits
(uint_fast16_t ). |
PRIxFAST32 /PRIXFAST32 | Hexadecimal placeholder string for the fastest
unsigned integer type with a width of at least 32 bits
(uint_fast32_t ). |
PRIxFAST64 /PRIXFAST64 | Octal placeholder string for the fastest
unsigned integer type with a width of at least 64 bits
(uint_fast64_t ), where supported (see Attention
note). |
PRIoLEAST8 | Octal placeholder string for an unsigned
integer type with a width of at least 8 bits
(uint_least8_t ). |
PRIoLEAST16 | Octal placeholder string for an unsigned
integer type with a width of at least 16 bits
(uint_least16_t ). |
PRIoLEAST32 | Octal placeholder string for an unsigned
integer type with a width of at least 32 bits
(uint_least32_t ). |
PRIoLEAST64 | Octal placeholder string for an unsigned
integer type with a width of at least 64 bits
(uint_least64_t ), where supported (see Attention
note). |
PRIuLEAST8 | Unsigned decimal placeholder string for an
unsigned integer type with a width of at least 8 bits
(uint_least8_t ). |
PRIuLEAST16 | Unsigned decimal placeholder string for an
unsigned integer type with a width of at least 16 bits
(uint_least16_t ). |
PRIuLEAST32 | Unsigned decimal placeholder string for an
unsigned integer type with a width of at least 32 bits
(uint_least32_t ). |
PRIuLEAST64 | Unsigned decimal placeholder string for an
unsigned integer type with a width of at least 64 bits
(uint_least64_t ), where supported (see Attention
note). |
PRIxLEAST8 /PRIXLEAST8 | Hexadecimal placeholder string for an unsigned
integer type with a width of at least 8 bits
(uint_least8_t ). |
PRIxLEAST16 /PRIXLEAST16 | Hexadecimal placeholder string for an unsigned
integer type with a width of at least 16 bits
(uint_least16_t ). |
PRIxLEAST32 /PRIXLEAST32 | Hexadecimal placeholder string for an unsigned
integer type with a width of at least 32 bits
(uint_least32_t ) |
PRIxLEAST64 /PRIXLEAST64 | Hexadecimal placeholder string for an unsigned
integer type with a width of at least 64 bits
(uint_least64_t ). |
PRIoMAX | Octal placeholder string for an unsigned
integer type with maximum width (uintmax_t ). |
PRIuMAX | Unsigned decimal placeholder string for an
unsigned integer type with maximum width
(uintmax_t ). |
PRIxMAX /PRIXMAX | Hexadecimal placeholder string for an unsigned
integer type with maximum width (uintmax_t ). |
PRIoPTR | Octal placeholder string for the
uintptr_t type. |
PRIuPTR | Unsigned decimal placeholder string for the
uintptr_t type. |
PRIxPTR /PRIXPTR | Hexadecimal placeholder string for the
uintptr_t type. |
Example
See the notes at the beginning of this chapter or section for
information on using printf()
or scanf()
(and other functions reading and writing the stdin
or
stdout
streams) in the example code.
#include <stdio.h>
#include <inttypes.h>
uint8_t u8 = 23;
uint_least32_t ul32 = 0x345678;
int main(void)
{
printf("u8 value: %" PRIo8 "\n", u8);
printf("ul32 value: %" PRIxLEAST32 "\n", ul32);
}