6.7.5 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 NameDescription
SCNo8Octal placeholder string for an unsigned 8-bit integer type (uint8_t).
SCNo16Octal placeholder string for an unsigned 16-bit integer type (uint16_t).
SCNo32Octal placeholder string for an unsigned 32-bit integer type (uint32_t).
SCNo64Octal placeholder string for an unsigned 64-bit integer type (uint64_t), where supported (see Attention note).
SCNu8Unsigned decimal placeholder string for an unsigned 8-bit integer type (uint8_t).
SCNu16Unsigned decimal placeholder string for an unsigned 16-bit integer type (uint16_t).
SCNu32Unsigned decimal placeholder string for an unsigned 32-bit integer type (uint32_t).
SCNu64Unsigned decimal placeholder string for an unsigned 64-bit integer type (uint64_t), where supported (see Attention note).
SCNx8Hexadecimal placeholder string for an unsigned 8-bit integer type (uint8_t).
SCNx16Hexadecimal placeholder string for an unsigned 16-bit integer type (uint16_t).
SCNx32Hexadecimal placeholder string for an unsigned 32-bit integer type (uint32_t).
SCNx64Hexadecimal placeholder string for an unsigned 64-bit integer type (uint64_t), where supported (see Attention note).
SCNoFAST8Octal placeholder string for the fastest unsigned integer type with a width of at least 8 bits (uint_fast8_t).
SCNoFAST16Octal placeholder string for the fastest unsigned integer type with a width of at least 16 bits (uint_fast16_t).
SCNoFAST32Octal placeholder string for the fastest unsigned integer type with a width of at least 32 bits (uint_fast32_t).
SCNoFAST64Octal placeholder string for the fastest unsigned integer type with a width of at least 64 bits (uint_fast64_t), where supported (see Attention note).
SCNuFAST8Unsigned decimal placeholder string for the fastest unsigned integer type with a width of at least 8 bits (uint_fast8_t).
SCNuFAST16Unsigned decimal placeholder string for the fastest unsigned integer type with a width of at least 16 bits (uint_fast16_t).
SCNuFAST32Unsigned decimal placeholder string for the fastest unsigned integer type with a width of at least 32 bits (uint_fast32_t).
SCNuFAST64Unsigned 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).
SCNxFAST8Hexadecimal placeholder string for the fastest unsigned integer type with a width of at least 8 bits (uint_fast8_t).
SCNxFAST16Hexadecimal placeholder string for the fastest unsigned integer type with a width of at least 16 bits (uint_fast16_t).
SCNxFAST32Hexadecimal placeholder string for the fastest unsigned integer type with a width of at least 32 bits (uint_fast32_t).
SCNxFAST64Octal placeholder string for the fastest unsigned integer type with a width of at least 64 bits (uint_fast64_t), where supported (see Attention note).
SCNoLEAST8Octal placeholder string for a unsigned integer type with a width of at least 8 bits (uint_least8_t).
SCNoLEAST16Octal placeholder string for a unsigned integer type with a width of at least 16 bits (uint_least8_t).
SCNoLEAST32Octal placeholder string for a unsigned integer type with a width of at least 32 bits (uint_least8_t).
SCNoLEAST64Octal placeholder string for a unsigned integer type with a width of at least 64 bits (uint_least8_t), where supported.
SCNuLEAST8Unsigned decimal placeholder string for a unsigned integer type with a width of at least 8 bits (uint_least8_t).
SCNuLEAST16Unsigned decimal placeholder string for a unsigned integer type with a width of at least 16 bits (uint_least8_t).
SCNuLEAST32Unsigned decimal placeholder string for a unsigned integer type with a width of at least 32 bits (uint_least8_t).
SCNuLEAST64Unsigned decimal placeholder string for a unsigned integer type with a width of at least 64 bits (uint_least8_t), where supported.
SCNxLEAST8Hexadecimal placeholder string for a unsigned integer type with a width of at least 8 bits (uint_least8_t).
SCNxLEAST16Hexadecimal placeholder string for a unsigned integer type with a width of at least 16 bits (uint_least8_t).
SCNxLEAST32Hexadecimal placeholder string for a unsigned integer type with a width of at least 32 bits (uint_least8_t).
SCNxLEAST64Hexadecimal placeholder string for a unsigned integer type with a width of at least 64 bits (uint_least8_t).
SCNoMAXOctal placeholder string for a unsigned integer type with maximum width (uintmax_t).
SCNuMAXUnsigned decimal placeholder string for a unsigned integer type with maximum width (uintmax_t).
SCNxMAXHexadecimal placeholder string for a unsigned integer type with maximum width (uintmax_t).
SCNoPTROctal placeholder string for the uintptr_t type.
SCNuPTRUnsigned decimal placeholder string for the uintptr_t type.
SCNxPTRHexadecimal 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);
}