| macro | description | example |
|---|---|---|
PRIxMAX | printf specifier for intmax_t | PRIiMAX is the equivalent of i (in "%i") for intmax_t values |
PRIxN | printf specifier for intN_t | PRId16 is the equivalent of d (in "%d") for int16_t values |
PRIxLEASTN | printf specifier for int_leastN_t | PRIuLEAST32 is the equivalent of u (in "%u") for uint32_t values |
PRIxFASTN | printf specifier for int_fastN_t | PRIxFAST8 is the equivalent of x (in "%x") for uint8_t values |
PRIxPTR | printf specifier for intptr_t | PRIuPTR is the equivalent of u (in "%u") for uintptr_t values |
SCNxMAX | scanf specifier for intmax_t | SCNiMAX is the equivalent of i (in "%i") for intmax_t values |
SCNxN | scanf specifier for intN_t | SCNd16 is the equivalent of d (in "%d") for int16_t values |
SCNxLEASTN | scanf specifier for int_leastN_t | SCNuLEAST32 is the equivalent of u (in "%u") for uint32_t values |
SCNxFASTN | scanf specifier for int_fastN_t | SCNxFAST8 is the equivalent of x (in "%x") for uint8_t values |
SCNxPTR | scanf specifier for intptr_t | SCNuPTR is the equivalent of u (in "%u") for uintptr_t values |
d, i, o,u or x (for the printf specifiers this can also be an uppercase X).*i and d, and unsigned for o, u, x and X.| 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); |
| Type | description |
|---|---|
| imaxdiv_t | Type returned by imaxdiv, which is the div_t equivalent for intmax_t . |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/* example of <inttypes.h> */
#include <stdio.h> /* printf, scanf, fgets, stdin, NULL */
#include <stdint.h> /* intmax_t */
#include <inttypes.h> /* strtoimax, PRIdMAX, SCNdMAX */
int main ()
{
char buffer[80];
intmax_t foo,bar;
printf ("Please, enter a number: ");
fgets (buffer,80,stdin);
foo = strtoimax (buffer,NULL,10);
printf ("Thanks for entering %" PRIdMAX ".\n", foo);
printf ("Please, enter another number: ");
scanf ("%" SCNdMAX,&bar);
printf ("%" PRIdMAX " by %" PRIdMAX " is %" PRIdMAX, foo, bar, foo*bar);
return 0;
}
Please, enter a number: 10 Thanks for entering 10. Please, enter another number: 20 10 by 20 is 200