Use portable names for integer types - C Data Type

C examples for Data Type:int

Description

Use portable names for integer types

Demo Code

#include <stdio.h>
#include <inttypes.h> // supports portable types

int main(void){

    int32_t me32;     // me32 a 32-bit signed variable
    /*from  w  w  w.ja  va2  s.  c o m*/
    me32 = 12345678;
    printf("First, assume int32_t is int: ");
    printf("me32 = %d\n", me32);
    printf("Next, let's not make any assumptions.\n");
    printf("Instead, use a \"macro\" from inttypes.h: ");
    printf("me32 = %" PRId32 "\n", me32);
    
    return 0;
}

Result


Related Tutorials