header

<cinttypes> (inttypes.h)

C integer types
Header with library support for width-based integral 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:
macrodescriptionexample
PRIxMAXprintf specifier for intmax_tPRIiMAX is the equivalent of i (in "%i") for intmax_t values
PRIxNprintf specifier for intN_tPRId16 is the equivalent of d (in "%d") for int16_t values
PRIxLEASTNprintf specifier for int_leastN_tPRIuLEAST32 is the equivalent of u (in "%u") for uint32_t values
PRIxFASTNprintf specifier for int_fastN_tPRIxFAST8 is the equivalent of x (in "%x") for uint8_t values
PRIxPTRprintf specifier for intptr_tPRIuPTR is the equivalent of u (in "%u") for uintptr_t values
SCNxMAXscanf specifier for intmax_tSCNiMAX is the equivalent of i (in "%i") for intmax_t values
SCNxNscanf specifier for intN_tSCNd16 is the equivalent of d (in "%d") for int16_t values
SCNxLEASTNscanf specifier for int_leastN_tSCNuLEAST32 is the equivalent of u (in "%u") for uint32_t values
SCNxFASTNscanf specifier for int_fastN_tSCNxFAST8 is the equivalent of x (in "%x") for uint8_t values
SCNxPTRscanf specifier for intptr_tSCNuPTR is the equivalent of u (in "%u") for uintptr_t values
Where:
  • x is one of d, i, o,u or x (for the printf specifiers this can also be an uppercase X).*
  • N is 8, 16, 32, 64, or any other type width supported by the library in <cstdint>.
* The specifier assumes the type to be signed for 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:
functiondescription
imaxabsequivalent to abs for intmax_t:
intmax_t imaxabs (intmax_t n);
imaxdivequivalent to div for intmax_t:
imaxdiv_t imaxdiv (intmax_t numer, intmax_t denom);
strtoimaxequivalent to strtol for intmax_t:
intmax_t strtoimax (const char* str, char** endptr, int base);
strtoumaxequivalent to strtoul for uintmax_t:
uintmax_t strtoumax (const char* str, char** endptr, int base);
wcstoimaxequivalent to wcstol for intmax_t:
intmax_t wcstoimax (const wchar_t* wcs, wchar_t** endptr, int base);
wcstoumaxequivalent 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

Typedescription
imaxdiv_tType returned by imaxdiv, which is the div_t equivalent for intmax_t.

Example

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;
}


Possible output:

Please, enter a number: 10
Thanks for entering 10.
Please, enter another number: 20
10 by 20 is 200
<var id="pwjBlLZ"><strike id="pwjBlLZ"></strike></var>
<ins id="pwjBlLZ"></ins>
<ins id="pwjBlLZ"></ins>
<cite id="pwjBlLZ"><dl id="pwjBlLZ"></dl></cite>
<ins id="pwjBlLZ"></ins>
<cite id="pwjBlLZ"></cite><var id="pwjBlLZ"><dl id="pwjBlLZ"></dl></var><ins id="pwjBlLZ"><strike id="pwjBlLZ"><menuitem id="pwjBlLZ"></menuitem></strike></ins>
<menuitem id="pwjBlLZ"><dl id="pwjBlLZ"><progress id="pwjBlLZ"></progress></dl></menuitem><var id="pwjBlLZ"><strike id="pwjBlLZ"></strike></var><ins id="pwjBlLZ"><strike id="pwjBlLZ"><menuitem id="pwjBlLZ"></menuitem></strike></ins>
<var id="pwjBlLZ"><strike id="pwjBlLZ"></strike></var>
<var id="pwjBlLZ"><strike id="pwjBlLZ"></strike></var>
<ins id="pwjBlLZ"><video id="pwjBlLZ"><menuitem id="pwjBlLZ"></menuitem></video></ins>
<ins id="pwjBlLZ"><strike id="pwjBlLZ"></strike></ins>
<cite id="pwjBlLZ"></cite>
<var id="pwjBlLZ"><dl id="pwjBlLZ"><progress id="pwjBlLZ"></progress></dl></var><cite id="pwjBlLZ"><strike id="pwjBlLZ"><thead id="pwjBlLZ"></thead></strike></cite>
<ins id="pwjBlLZ"></ins><var id="pwjBlLZ"><strike id="pwjBlLZ"></strike></var><var id="pwjBlLZ"></var>
  • 8957701587 2018-02-23
  • 3891941586 2018-02-23
  • 6039851585 2018-02-23
  • 2573991584 2018-02-23
  • 7728781583 2018-02-23
  • 3731582 2018-02-23
  • 1007451581 2018-02-22
  • 8908121580 2018-02-22
  • 141161579 2018-02-22
  • 9421578 2018-02-22
  • 2826901577 2018-02-22
  • 3647361576 2018-02-22
  • 5717551575 2018-02-22
  • 523811574 2018-02-22
  • 6439871573 2018-02-22
  • 8109431572 2018-02-22
  • 8757321571 2018-02-22
  • 5265111570 2018-02-22
  • 3351351569 2018-02-22
  • 5109361568 2018-02-22