Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

C programming/inttypes.h

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

The inttypes.h file is a C header file that is part of the C standard library and API. It was added with the 1999 version of the ISO C standard (known as C99). It includes the stdint.h header and defines a number of macros for using it with the printf and scanf family of functions, as well as functions for working with the intmax_t type. Naming Convention and format specifiers for Macros The macros defined in inttypes.h follow a regular pattern to simplify usage. The pattern followed is as follows http://manpages.ubuntu.com/manpages/gutsy/man7/inttypes.h.7posix.html : First three characters PRI for output format (printf, fwprintf, wprintf, etc.) SCN for input format (scanf, fwscanf, etc.) Fourth character d for decimal formatting x for hexadecimal formatting o for octal formatting u for unsigned int formatting i for integer formatting Remaining Characters N for N bit size assignment to the data type (Eg. 32 for 32-bit size for integer, 16 for 16-bit size for unsigned int and so on) PTR for pointer MAX for maximum supported bit size FAST, whose meaning is not clearly defined and is left to the implementation to decide what is meant by a "fast" integer data type. Syntaxes The following table gives syntax used for various data types listed in inttypes.hhttp://en.cppreference.com/w/cpp/types/integerhttp://linux.die.net/man/3/int64_t: Fixed width integer signed unsigned8 bit int8_t uint8_t16 bit int16_t uint16_t32 bit int32_t uint32_t64 bit int64_t uint64_t Small & fixed integer types signed unsigned8 bit int_least8_t uint_least8_t16 bit int_least16_t uint_least16_t32 bit int_least32_t uint_least32_t64 bit int_least64_t uint_least64_t Fast & fixed integer types signed unsigned8 bit int_fast8_t uint_fast8_t16 bit int_fast16_t uint_fast16_t32 bit int_fast32_t uint_fast32_t64 bit int_fast64_t uint_fast64_t Rationale The difference in processing speeds in different processors like 16-bit, 32-bit and 64-bit systems, called for a uniform size for various data types. ISO/IEC 9899:1990 specified that the language should support basic data types like char, int, short and long but did not restrict the minimum or maximum size for these data types, except that int be at least 16-bits long and long be 32-bits long. In 16-bit systems, most implementations assigned 8, 16, 16 and 32 bits for char, short, int and long data types, respectively. In 32-bit systems, it was 8, 16, 32 and 32 bits for char, short, int and long data types. The difference in size of int caused problems to users who migrated from one system to another. The main purpose of including this header file is to restrict, or in other words, limit the exact size of int data type to a particular value(may be 16 bits or 32 bits)The Open Group Specifications Issue 6 Application Usage and Rationale http://pubs.opengroup.org/onlinepubs/009604599/basedefs/inttypes.h.html The IEEE and The Open Group. It can also be used to limit the size of data type modifiers like unsigned int and signed int to specific values by using the macros listed in the header file.The Open Group Specifications Issue 6 Application Usage and Rationale http://pubs.opengroup.org/onlinepubs/009604599/basedefs/inttypes.h.html The IEEE and The Open Group Base 14 September, 2011 See also wchar.h limits.h References External links inttypes.h header file for Visual C++ (requires a compatible stdint.h). C++ reference for fixed width integer types inherited from C Macro definitions and their interpretation in inttypes.h Writing machine-independent code Apple's open source code for inttypes.h ansi.h and minix/sys_config.h sys/types.h sys/dir.h