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 Name Description
SCNd8 Decimal placeholder string for a signed 8-bit integer type (int8_t).
SCNd16 Decimal placeholder string for a signed 16-bit integer type (int16_t).
SCNd32 Decimal placeholder string for a signed 32-bit integer type (int32_t).
SCNd64 Decimal placeholder string for a signed 64-bit integer type (int64_t), where supported (see Attention note).
SCNi8 Integer placeholder string for a signed 8-bit integer type (int8_t).
SCNi16 Integer placeholder string for a signed 16-bit integer type (int16_t).
SCNi32 Integer placeholder string for a signed 32-bit integer type (int32_t).
SCNi64 Integer placeholder string for a signed 64-bit integer type (int64_t), where supported (see Attention note).
SCNdFAST8 Decimal placeholder string for the fastest signed integer type with a width of at least 8 bits (int_fast8_t).
SCNdFAST16 Decimal placeholder string for the fastest signed integer type with a width of at least 16 bits (int_fast16_t).
SCNdFAST32 Decimal placeholder string for the fastest signed integer type with a width of at least 32 bits (int_fast32_t).
SCNdFAST64 Decimal placeholder string for the fastest signed integer type with a width of at least 64 bits (int_fast64_t), where supported (see Attention note).
SCNiFAST8 Integer placeholder string for the fastest signed integer type with a width of at least 8 bits (int_fast8_t).
SCNiFAST16 Integer placeholder string for the fastest signed integer type with a width of at least 16 bits (int_fast16_t).
SCNiFAST32 Integer placeholder string for the fastest signed integer type with a width of at least 32 bits (int_fast32_t).
SCNiFAST64 Integer placeholder string for the fastest signed integer type with a width of at least 64 bits (int_fast64_t), where supported (see Attention note).
SCNdLEAST8 Decimal placeholder string for a signed integer type with a width of at least 8 bits (int_least8_t).
SCNdLEAST16 Decimal placeholder string for a signed integer type with a width of at least 16 bits (int_least16_t).
SCNdLEAST32 Decimal placeholder string for a signed integer type with a width of at least 32 bits (int_least32_t).
SCNdLEAST64 Decimal placeholder string for a signed integer type with a width of at least 64 bits (int_least64_t), where supported (see Attention note).
SCNiLEAST8 Integer placeholder string for a signed integer type with a width of at least 8 bits (int_least8_t).
SCNiLEAST16 Integer placeholder string for a signed integer type with a width of at least 16 bits (int_least16_t).
SCNiLEAST32 Integer placeholder string for a signed integer type with a width of at least 32 bits (int_least32_t).
SCNiLEAST64 Integer placeholder string for a signed integer type with a width of at least 64 bits (int_least64_t), where supported (see Attention note).
SCNdMAX Decimal placeholder string for a signed integer type with maximum width (intmax_t).
SCNiMAX Integer placeholder string for a signed integer type with maximum width (intmax_t).
SCNdPTR Decimal placeholder string for the intptr_t type.
SCNiPTR Integer 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);
}