← GCC/C Index

🔢 <stdint.h> — Fixed-Width Integer Types (C99+)

Guarantees exact-width integers regardless of platform. Essential for portable code, network protocols, and embedded systems.

Include: #include <stdint.h> | Compile: gcc -Wall -o prog prog.c

📋 Functions & Macros

NamePrototype / ValueDescription
int8_ttypedefSigned 8-bit integer (-128 to 127)
uint8_ttypedefUnsigned 8-bit integer (0 to 255)
int16_ttypedefSigned 16-bit integer
uint16_ttypedefUnsigned 16-bit integer
int32_ttypedefSigned 32-bit integer
uint32_ttypedefUnsigned 32-bit integer
int64_ttypedefSigned 64-bit integer
uint64_ttypedefUnsigned 64-bit integer
intptr_ttypedefSigned integer wide enough to hold a pointer
uintptr_ttypedefUnsigned integer wide enough to hold a pointer
INT8_MAX127Maximum value of int8_t
UINT8_MAX255Maximum value of uint8_t
INT32_MAX2147483647Maximum value of int32_t
INT64_MAX9223372036854775807Maximum value of int64_t

💡 Example Program

Copy, save as demo.c, and compile with the command shown at the bottom.

#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>

int main(void) {
    int8_t   a = 127;
    uint8_t  b = 255;
    int32_t  c = INT32_MAX;
    uint64_t d = UINT64_MAX;

    printf("int8_t   max = %"PRId8"\n",  a);
    printf("uint8_t  max = %"PRIu8"\n",  b);
    printf("int32_t  max = %"PRId32"\n", c);
    printf("uint64_t max = %"PRIu64"\n", d);
    printf("sizeof(int32_t) = %zu bytes\n", sizeof(int32_t));
    return 0;
}
/* Compile: gcc -Wall -std=c99 -o stdint_demo stdint_demo.c */

← <errno.h>  |  🏠 Index  |  <stdbool.h> →