The C99 standard includes definitions of several new integer types to enhance the portability of programs.[2] The already available basic integer types were deemed insufficient, because their actual sizes are implementation defined and may vary across different systems. The new types are especially useful in embedded environments where hardware usually supports only several types and that support varies between different environments. All new types are defined in header (cinttypes header in C++) and also are available at header

Is this the correct answer ? if so can anybody explain it to me?

  • please can you explain why do we need this portability in our code
    – Ashish
    Aug 23 '18 at 11:04

The passage you cite from Wikipedia is, of course, related but does not directly answer the question of "What is the function of stdint.h?" Try rephrasing it to actually answer the question.

It basically sais that if you want your program to work universally in any system environments you cannot rely on using basic data types like int or long long. That is because you cannot be sure that the actual size of int will always be 32 bits, and long long will always be 64 bits. Instead, you can include stdint.h header file which contains the definition of new integer types. With them, you can be more specific in what you want from your integer. For example, you can use fixed-width integer type int32_t, which is guaranteed to have 32 bits anywhere.

  • Very useful information! Thanks!
    – iamcarlos
    Mar 24 '19 at 0:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .