728x90
728x170
*[header][C library] cinttypes (inttypes.h) (C++11)
<cinttypes> (inttypes.h)
C integer types
Including this header automatically includes also <cstdint> (which defines width-based integral types).
Macros
The following macros expand to character string literals that contain a printf or scanf specifier suitable to be used with specific width-based integral types:macro | description | example |
---|---|---|
PRI xMAX | printf specifier for intmax_t | PRIiMAX is the equivalent of i (in "%i" ) for intmax_t values |
PRI xN | printf specifier for int N_t | PRId16 is the equivalent of d (in "%d" ) for int16_t values |
PRI xLEAST N | printf specifier for int_least N_t | PRIuLEAST32 is the equivalent of u (in "%u" ) for uint32_t values |
PRI xFAST N | printf specifier for int_fast N_t | PRIxFAST8 is the equivalent of x (in "%x" ) for uint8_t values |
PRI xPTR | printf specifier for intptr_t | PRIuPTR is the equivalent of u (in "%u" ) for uintptr_t values |
SCN xMAX | scanf specifier for intmax_t | SCNiMAX is the equivalent of i (in "%i" ) for intmax_t values |
SCN xN | scanf specifier for int N_t | SCNd16 is the equivalent of d (in "%d" ) for int16_t values |
SCN xLEAST N | scanf specifier for int_least N_t | SCNuLEAST32 is the equivalent of u (in "%u" ) for uint32_t values |
SCN xFAST N | scanf specifier for int_fast N_t | SCNxFAST8 is the equivalent of x (in "%x" ) for uint8_t values |
SCN xPTR | scanf specifier for intptr_t | SCNuPTR is the equivalent of u (in "%u" ) for uintptr_t values |
- x is one of
d
,i
,o
,u
orx
(for the printf specifiers this can also be an uppercaseX
).* - N is 8, 16, 32, 64, or any other type width supported by the library in <cstdint>.
i
and d
, and unsigned for o
, u
, x
and X
.Functions
This header also declares the following functions, that adapt functions in <cstdlib> and <cwchar> for intmax_t:function | description |
---|---|
imaxabs | equivalent to abs for intmax_t:intmax_t imaxabs (intmax_t n); |
imaxdiv | equivalent to div for intmax_t:imaxdiv_t imaxdiv (intmax_t numer, intmax_t denom); |
strtoimax | equivalent to strtol for intmax_t:intmax_t strtoimax (const char* str, char** endptr, int base); |
strtoumax | equivalent to strtoul for uintmax_t:uintmax_t strtoumax (const char* str, char** endptr, int base); |
wcstoimax | equivalent to wcstol for intmax_t:intmax_t wcstoimax (const wchar_t* wcs, wchar_t** endptr, int base); |
wcstoumax | equivalent to wcstoul for uintmax_t:uintmax_t wcstoumax (const wchar_t* wcs, wchar_t** endptr, int base); |
In C++, including this header also provides overloads of abs and div for intmax_t (equivalent to the functions above) unless intmax_t is an alias of a fundamental type.
Types
Type | description |
---|---|
imaxdiv_t | Type returned by imaxdiv, which is the div_t equivalent for intmax_t. |
Example
|
|
Possible output:
Please, enter a number: 10 Thanks for entering 10. Please, enter another number: 20 10 by 20 is 200 |
728x90
그리드형(광고전용)
'Programming > C++' 카테고리의 다른 글
[header][C library] cmath (math.h) (0) | 2017.11.08 |
---|---|
[header][C library] clocale (locale.h) (0) | 2017.11.08 |
[header][C library] climits (limits.h) (0) | 2017.11.08 |
[header][C library] ciso646 (iso646.h) (0) | 2017.11.08 |
[header][C library] cfloat (float.h) (0) | 2017.11.08 |
[header][C library] cfenv (fenv.h) (C++11) (0) | 2017.11.08 |
[header][C library] cerrno (errno.h) (0) | 2017.11.08 |
[header][C library] cctype (ctype.h) (0) | 2017.11.08 |