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.

Attention: The format macros for 64-bit quantities are not supported when using 8-bit AVR, Baseline, or non-enhanced Mid-range PIC devices with MPLAB XC8.

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 NameDescription
PRIo8Octal placeholder string for an unsigned 8-bit integer type (uint8_t).
PRIo16Octal placeholder string for an unsigned 16-bit integer type (uint16_t).
PRIo32Octal placeholder string for an unsigned 32-bit integer type (uint32_t).
PRIo64Octal placeholder string for an unsigned 64-bit integer type (uint64_t), where supported (see Attention note).
PRIu8Unsigned decimal placeholder string for an unsigned 8-bit integer type (uint8_t).
PRIu16Unsigned decimal placeholder string for an unsigned 16-bit integer type (uint16_t).
PRIu32Unsigned decinmal placeholder string for an unsigned 32-bit integer type (uint32_t).
PRIu64Unsigned decimal placeholder string for an unsigned 64-bit integer type (uint64_t), where supported (see Attention note).
PRIx8/ PRIX8Hexadecimal placeholder string for an unsigned 8-bit integer type (uint8_t).
PRIx16/ PRIX16Hexadecimal placeholder string for an unsigned 16-bit integer type (uint16_t).
PRIx32/ PRIX32Hexadecimal placeholder string for an unsigned 32-bit integer type (uint32_t).
PRIx64/ PRIX64Hexadecimal placeholder string for an unsigned 64-bit integer type (uint64_t), where supported (see Attention note).
PRIoFAST8Octal placeholder string for the fastest unsigned integer type with a width of at least 8 bits (uint_fast8_t).
PRIoFAST16Octal placeholder string for the fastest unsigned integer type with a width of at least 16 bits (uint_fast16_t).
PRIoFAST32Octal placeholder string for the fastest unsigned integer type with a width of at least 32 bits (uint_fast32_t).
PRIoFAST64Octal placeholder string for the fastest unsigned integer type with a width of at least 64 bits (uint_fast64_t), where supported (see Attention note).
PRIuFAST8Unsigned decimal placeholder string for the fastest unsigned integer type with a width of at least 8 bits (uint_fast8_t).
PRIuFAST16Unsigned decimal placeholder string for the fastest unsigned integer type with a width of at least 16 bits (uint_fast16_t).
PRIuFAST32Unsigned decimal placeholder string for the fastest unsigned integer type with a width of at least 32 bits (uint_fast32_t).
PRIuFAST64Unsigned 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/PRIXFAST8Hexadecimal placeholder string for the fastest unsigned integer type with a width of at least 8 bits (uint_fast8_t).
PRIxFAST16/PRIXFAST16Hexadecimal placeholder string for the fastest unsigned integer type with a width of at least 16 bits (uint_fast16_t).
PRIxFAST32/PRIXFAST32Hexadecimal placeholder string for the fastest unsigned integer type with a width of at least 32 bits (uint_fast32_t).
PRIxFAST64/PRIXFAST64Octal placeholder string for the fastest unsigned integer type with a width of at least 64 bits (uint_fast64_t), where supported (see Attention note).
PRIoLEAST8Octal placeholder string for an unsigned integer type with a width of at least 8 bits (uint_least8_t).
PRIoLEAST16Octal placeholder string for an unsigned integer type with a width of at least 16 bits (uint_least16_t).
PRIoLEAST32Octal placeholder string for an unsigned integer type with a width of at least 32 bits (uint_least32_t).
PRIoLEAST64Octal placeholder string for an unsigned integer type with a width of at least 64 bits (uint_least64_t), where supported (see Attention note).
PRIuLEAST8Unsigned decimal placeholder string for an unsigned integer type with a width of at least 8 bits (uint_least8_t).
PRIuLEAST16Unsigned decimal placeholder string for an unsigned integer type with a width of at least 16 bits (uint_least16_t).
PRIuLEAST32Unsigned decimal placeholder string for an unsigned integer type with a width of at least 32 bits (uint_least32_t).
PRIuLEAST64Unsigned 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/PRIXLEAST8Hexadecimal placeholder string for an unsigned integer type with a width of at least 8 bits (uint_least8_t).
PRIxLEAST16/PRIXLEAST16Hexadecimal placeholder string for an unsigned integer type with a width of at least 16 bits (uint_least16_t).
PRIxLEAST32/PRIXLEAST32Hexadecimal placeholder string for an unsigned integer type with a width of at least 32 bits (uint_least32_t)
PRIxLEAST64/PRIXLEAST64Hexadecimal placeholder string for an unsigned integer type with a width of at least 64 bits (uint_least64_t).
PRIoMAXOctal placeholder string for an unsigned integer type with maximum width (uintmax_t).
PRIuMAXUnsigned decimal placeholder string for an unsigned integer type with maximum width (uintmax_t).
PRIxMAX/PRIXMAXHexadecimal placeholder string for an unsigned integer type with maximum width (uintmax_t).
PRIoPTROctal placeholder string for the uintptr_ttype.
PRIuPTRUnsigned decimal placeholder string for the uintptr_t type.
PRIxPTR/PRIXPTRHexadecimal 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);
}