6.7.4 Scan Format Macros for Signed Integers

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

Macro NameDescription
SCNd8Decimal placeholder string for a signed 8-bit integer type (int8_t).
SCNd16Decimal placeholder string for a signed 16-bit integer type (int16_t).
SCNd32Decimal placeholder string for a signed 32-bit integer type (int32_t).
SCNd64Decimal placeholder string for a signed 64-bit integer type (int64_t), where supported (see Attention note).
SCNi8Integer placeholder string for a signed 8-bit integer type (int8_t).
SCNi16Integer placeholder string for a signed 16-bit integer type (int16_t).
SCNi32Integer placeholder string for a signed 32-bit integer type (int32_t).
SCNi64Integer placeholder string for a signed 64-bit integer type (int64_t), where supported (see Attention note).
SCNdFAST8Decimal placeholder string for the fastest signed integer type with a width of at least 8 bits (int_fast8_t).
SCNdFAST16Decimal placeholder string for the fastest signed integer type with a width of at least 16 bits (int_fast16_t).
SCNdFAST32Decimal placeholder string for the fastest signed integer type with a width of at least 32 bits (int_fast32_t).
SCNdFAST64Decimal placeholder string for the fastest signed integer type with a width of at least 64 bits (int_fast64_t), where supported (see Attention note).
SCNiFAST8Integer placeholder string for the fastest signed integer type with a width of at least 8 bits (int_fast8_t).
SCNiFAST16Integer placeholder string for the fastest signed integer type with a width of at least 16 bits (int_fast16_t).
SCNiFAST32Integer placeholder string for the fastest signed integer type with a width of at least 32 bits (int_fast32_t).
SCNiFAST64Integer placeholder string for the fastest signed integer type with a width of at least 64 bits (int_fast64_t), where supported (see Attention note).
SCNdLEAST8Decimal placeholder string for a signed integer type with a width of at least 8 bits (int_least8_t).
SCNdLEAST16Decimal placeholder string for a signed integer type with a width of at least 16 bits (int_least16_t).
SCNdLEAST32Decimal placeholder string for a signed integer type with a width of at least 32 bits (int_least32_t).
SCNdLEAST64Decimal placeholder string for a signed integer type with a width of at least 64 bits (int_least64_t), where supported (see Attention note).
SCNiLEAST8Integer placeholder string for a signed integer type with a width of at least 8 bits (int_least8_t).
SCNiLEAST16Integer placeholder string for a signed integer type with a width of at least 16 bits (int_least16_t).
SCNiLEAST32Integer placeholder string for a signed integer type with a width of at least 32 bits (int_least32_t).
SCNiLEAST64Integer placeholder string for a signed integer type with a width of at least 64 bits (int_least64_t), where supported (see Attention note).
SCNdMAXDecimal placeholder string for a signed integer type with maximum width (intmax_t).
SCNiMAXInteger placeholder string for a signed integer type with maximum width (intmax_t).
SCNdPTRDecimal placeholder string for the intptr_t type.
SCNiPTRInteger placeholder string for the intptr_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>

int_least16_t l16;
intmax_t smax;

int main(void)
{
  scanf("%" SCNdLEAST16, &l16);
  scanf("%" SCNiMAX, &smax);
}