Scan Format Macros for Unsigned Integers

Placeholder macros that can be used with the scanf family of functions when reading in 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 reading in unsigned integer values.

Macro Name Description
SCNo8 Octal placeholder string for an unsigned 8-bit integer type (uint8_t).
SCNo16 Octal placeholder string for an unsigned 16-bit integer type (uint16_t).
SCNo32 Octal placeholder string for an unsigned 32-bit integer type (uint32_t).
SCNo64 Octal placeholder string for an unsigned 64-bit integer type (uint64_t), where supported (see Attention note).
SCNu8 Unsigned decimal placeholder string for an unsigned 8-bit integer type (uint8_t).
SCNu16 Unsigned decimal placeholder string for an unsigned 16-bit integer type (uint16_t).
SCNu32 Unsigned decimal placeholder string for an unsigned 32-bit integer type (uint32_t).
SCNu64 Unsigned decimal placeholder string for an unsigned 64-bit integer type (uint64_t), where supported (see Attention note).
SCNx8 Hexadecimal placeholder string for an unsigned 8-bit integer type (uint8_t).
SCNx16 Hexadecimal placeholder string for an unsigned 16-bit integer type (uint16_t).
SCNx32 Hexadecimal placeholder string for an unsigned 32-bit integer type (uint32_t).
SCNx64 Hexadecimal placeholder string for an unsigned 64-bit integer type (uint64_t), where supported (see Attention note).
SCNoFAST8 Octal placeholder string for the fastest unsigned integer type with a width of at least 8 bits (uint_fast8_t).
SCNoFAST16 Octal placeholder string for the fastest unsigned integer type with a width of at least 16 bits (uint_fast16_t).
SCNoFAST32 Octal placeholder string for the fastest unsigned integer type with a width of at least 32 bits (uint_fast32_t).
SCNoFAST64 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).
SCNuFAST8 Unsigned decimal placeholder string for the fastest unsigned integer type with a width of at least 8 bits (uint_fast8_t).
SCNuFAST16 Unsigned decimal placeholder string for the fastest unsigned integer type with a width of at least 16 bits (uint_fast16_t).
SCNuFAST32 Unsigned decimal placeholder string for the fastest unsigned integer type with a width of at least 32 bits (uint_fast32_t).
SCNuFAST64 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).
SCNxFAST8 Hexadecimal placeholder string for the fastest unsigned integer type with a width of at least 8 bits (uint_fast8_t).
SCNxFAST16 Hexadecimal placeholder string for the fastest unsigned integer type with a width of at least 16 bits (uint_fast16_t).
SCNxFAST32 Hexadecimal placeholder string for the fastest unsigned integer type with a width of at least 32 bits (uint_fast32_t).
SCNxFAST64 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).
SCNoLEAST8 Octal placeholder string for a unsigned integer type with a width of at least 8 bits (uint_least8_t).
SCNoLEAST16 Octal placeholder string for a unsigned integer type with a width of at least 16 bits (uint_least8_t).
SCNoLEAST32 Octal placeholder string for a unsigned integer type with a width of at least 32 bits (uint_least8_t).
SCNoLEAST64 Octal placeholder string for a unsigned integer type with a width of at least 64 bits (uint_least8_t), where supported.
SCNuLEAST8 Unsigned decimal placeholder string for a unsigned integer type with a width of at least 8 bits (uint_least8_t).
SCNuLEAST16 Unsigned decimal placeholder string for a unsigned integer type with a width of at least 16 bits (uint_least8_t).
SCNuLEAST32 Unsigned decimal placeholder string for a unsigned integer type with a width of at least 32 bits (uint_least8_t).
SCNuLEAST64 Unsigned decimal placeholder string for a unsigned integer type with a width of at least 64 bits (uint_least8_t), where supported.
SCNxLEAST8 Hexadecimal placeholder string for a unsigned integer type with a width of at least 8 bits (uint_least8_t).
SCNxLEAST16 Hexadecimal placeholder string for a unsigned integer type with a width of at least 16 bits (uint_least8_t).
SCNxLEAST32 Hexadecimal placeholder string for a unsigned integer type with a width of at least 32 bits (uint_least8_t).
SCNxLEAST64 Hexadecimal placeholder string for a unsigned integer type with a width of at least 64 bits (uint_least8_t).
SCNoMAX Octal placeholder string for a unsigned integer type with maximum width (uintmax_t).
SCNuMAX Unsigned decimal placeholder string for a unsigned integer type with maximum width (uintmax_t).
SCNxMAX Hexadecimal placeholder string for a unsigned integer type with maximum width (uintmax_t).
SCNoPTR Octal placeholder string for the uintptr_t type.
SCNuPTR Unsigned decimal placeholder string for the uintptr_t type.
SCNxPTR 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>

uint_least16_t ul16;
uintmax_t umax;

int
main(void)
{
  scanf("%" SCNxLEAST16, &ul16);
  scanf("%" SCNuMAX, &umax);
}