Defines macros for converting formatted text to integer types.
The inttypes.h header file defines macros that expand to a literal character string that forms a conversion specifier suitable for use with formatted input functions.
| Format | Type | Macro |
|---|---|---|
| decimal | int8_t | SCNd8 |
| decimal | int16_t | SCNd16 |
| decimal | int32_t | SCNd32 |
| decimal | int64_t | SCNd64 |
| decimal | int_least8_t | SCNdLEAST8 |
| decimal | int_least16_t | SCNdLEAST16 |
| decimal | int_least32_t | SCNdLEAST32 |
| decimal | int_least64_t | SCNdLEAST64 |
| decimal | int_fast8_t | SCNdFAST8 |
| decimal | int_fast16_t | SCNdFAST16 |
| decimal | int_fast32_t | SCNdFAST32 |
| decimal | int_fast64_t | SCNdFAST64 |
| decimal | intmax_t | SCNdMAX |
| decimal | intptr_t | SCNdPTR |
| octal, decimal, or hexadecimal | int8_t | SCNi8 |
| octal, decimal, or hexadecimal | int16_t | SCNi16 |
| octal, decimal, or hexadecimal | int32_t | SCNi32 |
| octal, decimal, or hexadecimal | int64_t | SCNi64 |
| octal, decimal, or hexadecimal | int_least8_t | SCNiLEAST8 |
| octal, decimal, or hexadecimal | int_least16_t | SCNiLEAST16 |
| octal, decimal, or hexadecimal | int_least32_t | SCNiLEAST32 |
| octal, decimal, or hexadecimal | int_least64_t | SCNiLEAST64 |
| octal, decimal, or hexadecimal | int_fast8_t | SCNiFAST8 |
| octal, decimal, or hexadecimal | int_fast16_t | SCNiFAST16 |
| octal, decimal, or hexadecimal | int_fast32_t | SCNiFAST32 |
| octal, decimal, or hexadecimal | int_fast64_t | SCNiFAST64 |
| octal, decimal, or hexadecimal | intmax_t | SCNiMAX |
| octal, decimal, or hexadecimal | intptr_t | SCNiPTR |
| unsigned octal | int8_t | SCNo8 |
| unsigned octal | int16_t | SCNo16 |
| unsigned octal | int32_t | SCNo32 |
| unsigned octal | int64_t | SCNo64 |
| unsigned octal | int_least8_t | SCNoLEAST8 |
| unsigned octal | int_least16_t | SCNoLEAST16 |
| unsigned octal | int_least32_t | SCNoLEAST32 |
| unsigned octal | int_least64_t | SCNoLEAST64 |
| unsigned octal | int_fast8_t | SCNoFAST8 |
| unsigned octal | int_fast16_t | SCNoFAST16 |
| unsigned octal | int_fast32_t | SCNoFAST32 |
| unsigned octal | int_fast64_t | SCNoFAST64 |
| unsigned octal | intmax_t | SCNoMAX |
| unsigned octal | intptr_t | SCNoPTR |
| unsigned decimal | int8_t | SCNu8 |
| unsigned decimal | int16_t | SCNu16 |
| unsigned decimal | int32_t | SCNu32 |
| unsigned decimal | int64_t | SCNu64 |
| unsigned decimal | int_least8_t | SCNuLEAST8 |
| unsigned decimal | int_least16_t | SCNuLEAST16 |
| unsigned decimal | int_least32_t | SCNuLEAST32 |
| unsigned decimal | int_least64_t | SCNuLEAST64 |
| unsigned decimal | int_fast8_t | SCNuFAST8 |
| unsigned decimal | int_fast16_t | SCNuFAST16 |
| unsigned decimal | int_fast32_t | SCNuFAST32 |
| unsigned decimal | int_fast64_t | SCNuFAST64 |
| unsigned decimal | intmax_t | SCNuMAX |
| unsigned decimal | intptr_t | SCNuPTR |
| unsigned hexadecimal | int8_t | SCNx8 |
| unsigned hexadecimal | int16_t | SCNx16 |
| unsigned hexadecimal | int32_t | SCNx32 |
| unsigned hexadecimal | int64_t | SCNx64 |
| unsigned hexadecimal | int_least8_t | SCNxLEAST8 |
| unsigned hexadecimal | int_least16_t | SCNxLEAST16 |
| unsigned hexadecimal | int_least32_t | SCNxLEAST32 |
| unsigned hexadecimal | int_least64_t | SCNxLEAST64 |
| unsigned hexadecimal | int_fast8_t | SCNxFAST8 |
| unsigned hexadecimal | int_fast16_t | SCNxFAST16 |
| unsigned hexadecimal | int_fast32_t | SCNxFAST32 |
| unsigned hexadecimal | int_fast64_t | SCNxFAST64 |
| unsigned hexadecimal | intmax_t | SCNxMAX |
| unsigned hexadecimal | intptr_t | SCNxPTR |
#include <stdio.h> #include <inttypes.h> int main(void) { int8_t i8; intmax_t im; printf("Enter an integer surrounded by ! marks.\n"); scanf("!%" SCNd8 "!", &i8); printf("Enter a large integer\n"); printf("in hexadecimal, octal, or decimal.\n"); scanf("%" SCNiMAX, &im); return 0; } Output: Enter an 8-bit integer surrounded by ! marks. !63! Enter a large integer in hexadecimal, octal, or decimal. 175812759