stdint.h
The inclusion of this file is a "minimum requirement" if you want to work with integer types with the specified width of C99 (ie, "int32_t", "uint16_t", etc.). If you include this file, you will receive definitions of these types so that you can use these types in variable and function declarations and perform operations on these data types.
inttypes.h
If you include this file, you will get everything that stdint.h provides (since inttypes.h includes stdint.h), but you will also get tools to do printf and scanf (and "fprintf", "fscanf", etc. ) with these types in a portable way. For example, you get the macro βPRIu16β so that you can print the integer uint16_t as follows:
#include <stdio.h> #include <inttypes.h> int main (int argc, char *argv[]) { // Only requires stdint.h to compile: uint16_t myvar = 65535; // Requires inttypes.h to compile: printf("myvar=%" PRIu16 "\n", myvar); }
Mikko Γstlund Feb 06 '12 at 15:00 2012-02-06 15:00
source share