( C99)
<stdint.h> | |
int8_tint16_tint32_tint64_t () |
8, 16, 32 64 2 ( ) ( ) |
int_fast8_tint_fast16_tint_fast32_tint_fast64_t |
8, 16, 32 64 ( ) |
int_least8_tint_least16_tint_least32_tint_least64_t |
8, 16, 32 64 ( ) |
intmax_t |
( ) |
intptr_t () |
, void ( ) |
uint8_tuint16_tuint32_tuint64_t () |
8, 16, 32 64 ( ) ( ) |
uint_fast8_tuint_fast16_tuint_fast32_tuint_fast64_t |
8, 16, 32 64 ( ) |
uint_least8_tuint_least16_tuint_least32_tuint_least64_t |
8, 16, 32 64 ( ) |
uintmax_t |
( ) |
uintptr_t () |
, void ( ) |
The implementation may define typedef names intN_t, int_fastN_t, int_leastN_t, uintN_t, uint_fastN_t, and uint_leastN_t when N is not 8, 16, 32 or 64. Typedef names of the form intN_t may only be defined if the implementation supports an integer type of that width with no padding. Thus, uint24_t denotes an unsigned integer type with a width of exactly 24 bits.
Each of the macros listed in below is defined if and only if the implementation defines the corresponding typedef name. The macros INTN_C and UINTN_C correspond to the typedef names int_leastN_t and uint_leastN_t, respectively.
<stdint.h> | |
Signed integers : width | |
INT8_WIDTHINT16_WIDTHINT32_WIDTHINT64_WIDTH (C23)() |
bit width of an object of type int8_t, int16_t, int32_t, int64_t (exactly 8, 16, 32, 64) () |
INT_FAST8_WIDTHINT_FAST16_WIDTHINT_FAST32_WIDTHINT_FAST64_WIDTH (C23) |
bit width of an object of type int_fast8_t, int_fast16_t, int_fast32_t, int_fast64_t () |
INT_LEAST8_WIDTHINT_LEAST16_WIDTHINT_LEAST32_WIDTHINT_LEAST64_WIDTH (C23) |
bit width of an object of type int_least8_t, int_least16_t, int_least32_t, int_least64_t () |
INTPTR_WIDTH (C23)() |
bit width of an object of type intptr_t () |
INTMAX_WIDTH (C23) |
bit width of an object of type intmax_t () |
Signed integers : minimum value | |
INT8_MININT16_MININT32_MININT64_MIN () |
std::int8_t, std::int16_t, std::int32_t std::int64_t () |
INT_FAST8_MININT_FAST16_MININT_FAST32_MININT_FAST64_MIN |
std::int_fast8_t, std::int_fast16_t, std::int_fast32_t std::int_fast64_t () |
INT_LEAST8_MININT_LEAST16_MININT_LEAST32_MININT_LEAST64_MIN |
std::int_least8_t, std::int_least16_t, std::int_least32_t std::int_least64_t () |
INTPTR_MIN () |
std::intptr_t () |
INTMAX_MIN |
std::intmax_t () |
Signed integers : maximum value | |
INT8_MAXINT16_MAXINT32_MAXINT64_MAX () |
std::int8_t, std::int16_t, std::int32_t std::int64_t () |
INT_FAST8_MAXINT_FAST16_MAXINT_FAST32_MAXINT_FAST64_MAX |
std::int_fast8_t, std::int_fast16_t, std::int_fast32_t std::int_fast64_t () |
INT_LEAST8_MAXINT_LEAST16_MAXINT_LEAST32_MAXINT_LEAST64_MAX |
std::int_least8_t, std::int_least16_t, std::int_least32_t std::int_least64_t () |
INTPTR_MAX () |
std::intptr_t () |
INTMAX_MAX |
std::intmax_t () |
Unsigned integers : width | |
UINT8_WIDTHUINT16_WIDTHUINT32_WIDTHUINT64_WIDTH (C23)() |
bit width of an object of type uint8_t, uint16_t, uint32_t, uint64_t (exactly 8, 16, 32, 64) () |
UINT_FAST8_WIDTHUINT_FAST16_WIDTHUINT_FAST32_WIDTHUINT_FAST64_WIDTH (C23) |
bit width of an object of type uint_fast8_t, uint_fast16_t, uint_fast32_t, uint_fast64_t () |
UINT_LEAST8_WIDTHUINT_LEAST16_WIDTHUINT_LEAST32_WIDTHUINT_LEAST64_WIDTH (C23) |
bit width of an object of type uint_least8_t, uint_least16_t, uint_least32_t, uint_least64_t () |
UINTPTR_WIDTH (C23)() |
bit width of an object of type uintptr_t () |
UINTMAX_WIDTH (C23) |
bit width of an object of type uintmax_t () |
Unsigned integers : maximum value | |
UINT8_MAXUINT16_MAXUINT32_MAXUINT64_MAX () |
std::uint8_t, std::uint16_t, std::uint32_t std::uint64_t () |
UINT_FAST8_MAXUINT_FAST16_MAXUINT_FAST32_MAXUINT_FAST64_MAX |
std::uint_fast8_t, std::uint_fast16_t, std::uint_fast32_t std::uint_fast64_t () |
UINT_LEAST8_MAXUINT_LEAST16_MAXUINT_LEAST32_MAXUINT_LEAST64_MAX |
std::uint_least8_t, std::uint_least16_t, std::uint_least32_t std::uint_least64_t () |
UINTPTR_MAX () |
std::uintptr_t () |
UINTMAX_MAX |
std::uintmax_t () |
-
#include <stdint.h>
UINT64_C(0x123) // might expand to 0x123ULL or 0x123UL
<inttypes.h> |
fprintf
Each of the PRI macros listed here is defined if and only if the implementation defines the corresponding typedef name.
| Equivalent for int orunsigned int
|
Description | Macros for data types | ||||
|---|---|---|---|---|---|---|
[u]intx_t |
[u]int_leastx_t |
[u]int_fastx_t |
[u]intmax_t |
[u]intptr_t | ||
d
|
output of a signed decimal integer value | PRIdx | PRIdLEASTx | PRIdFASTx | PRIdMAX | PRIdPTR |
i
|
PRIix | PRIiLEASTx | PRIiFASTx | PRIiMAX | PRIiPTR | |
u
|
output of an unsigned decimal integer value | PRIux | PRIuLEASTx | PRIuFASTx | PRIuMAX | PRIuPTR |
o
|
output of an unsigned octal integer value | PRIox | PRIoLEASTx | PRIoFASTx | PRIoMAX | PRIoPTR |
x
|
output of an unsigned lowercase hexadecimal integer value | PRIxx | PRIxLEASTx | PRIxFASTx | PRIxMAX | PRIxPTR |
X
|
output of an unsigned uppercase hexadecimal integer value | PRIXx | PRIXLEASTx | PRIXFASTx | PRIXMAX | PRIXPTR |
fscanf
Each of the SCN macros listed in here is defined if and only if the implementation defines the corresponding typedef name and has a suitable fscanf length modifier for the type.
| Equivalent for int orunsigned int
|
Description | Macros for data types | ||||
|---|---|---|---|---|---|---|
[u]intx_t |
[u]int_leastx_t |
[u]int_fastx_t |
[u]intmax_t |
[u]intptr_t | ||
d
|
input of a signed decimal integer value | SCNdx | SCNdLEASTx | SCNdFASTx | SCNdMAX | SCNdPTR |
i
|
input of a signed integer value (base is determined by the first characters parsed) | SCNix | SCNiLEASTx | SCNiFASTx | SCNiMAX | SCNiPTR |
u
|
input of an unsigned decimal integer value | SCNux | SCNuLEASTx | SCNuFASTx | SCNuMAX | SCNuPTR |
o
|
input of an unsigned octal integer value | SCNox | SCNoLEASTx | SCNoFASTx | SCNoMAX | SCNoPTR |
x
|
input of an unsigned hexadecimal integer value | SCNxx | SCNxLEASTx | SCNxFASTx | SCNxMAX | SCNxPTR |
#include <stdio.h>
#include <inttypes.h>
int main(void)
{
printf("%zu\n", sizeof(int64_t));
printf("%s\n", PRId64);
printf("%+"PRId64"\n", INT64_MIN);
printf("%+"PRId64"\n", INT64_MAX);
int64_t n = 7;
printf("%+"PRId64"\n", n);
}
:
8
lld
-9223372036854775808
+9223372036854775807
+7
- C17 (ISO/IEC 9899:2018):
- 7.8.1 Macros for format specifiers (. 158-159)
- 7.18 Integer types <stdint.h> (. 212-216)
- C11 (ISO/IEC 9899:2011):
- 7.8.1 Macros for format specifiers (. 217-218)
- 7.18 Integer types <stdint.h> (. 289-295)
- C99 (ISO/IEC 9899:1999):
- 7.8.1 Macros for format specifiers (. 198-199)
- 7.18 Integer types <stdint.h> (. 255-261)