Comprehensive reference for C primitive data types: int, float, double, char, size limits, format tokens, and signed or unsigned qualifiers.
What are Data Types in C?
In the C programming language, a data type defines the type and size of data associated with variables and function return values.
Because C is a statically typed language, every variable must have an explicit type declaration so the compiler can allocate the exact amount of stack or heap memory.
1. Basic Primitive Types Overview
The standard C language provides four fundamental primitive data types:
| Data Type | Typical Size | Typical Value Range | Printf Specifier |
|---|---|---|---|
char | 1 byte (8 bits) | -128 to 127 (signed) or 0 to 255 | %c |
int | 4 bytes (32 bits) | -2,147,483,648 to 2,147,483,647 | %d or %i |
float | 4 bytes (32 bits) | ~1.2E-38 to ~3.4E+38 (6 decimal places) | %f |
double | 8 bytes (64 bits) | ~2.3E-308 to ~1.7E+308 (15 decimal places) | %lf |
void | 0 bytes | Represents no value / empty parameter | N/A |
2. Type Modifiers (Short, Long, Signed, Unsigned)
You can alter the storage range and signedness of primitive types using modifier keywords:
c (ISO Standard)#include <stdio.h> #include <limits.h> int main() { short int smallNumber = 32767; unsigned int positiveOnly = 4000000000U; long long bigInt = 9223372036854775807LL; printf("Short int: %d (Size: %zu bytes)\n", smallNumber, sizeof(smallNumber)); printf("Unsigned int: %u (Size: %zu bytes)\n", positiveOnly, sizeof(positiveOnly)); printf("Long long: %lld (Size: %zu bytes)\n", bigInt, sizeof(bigInt)); return 0; }
3. Fixed-Width Integer Types (<stdint.h>)
For cross-platform systems programming and embedded systems, ISO C99 introduced exact-width integer definitions in <stdint.h>:
int8_t/uint8_t: Exactly 8 bits.int16_t/uint16_t: Exactly 16 bits.int32_t/uint32_t: Exactly 32 bits.int64_t/uint64_t: Exactly 64 bits.
c (ISO Standard)#include <stdio.h> #include <stdint.h> int main() { uint32_t packetId = 0xAABBCCDD; printf("Fixed-width 32-bit integer: 0x%X\n", packetId); return 0; }
4. Modern Boolean Type (bool in C23)
In C23, bool, true, and false are native language keywords. In older C99/C11 standards, including <stdbool.h> provides identical behavior.
Related References & Guides
- Look up formatted input and output tokens in C Format Specifiers Reference.
- Review mathematical and comparison operations in the C Operators Reference.
- Test variable memory limits in the Online C Compiler.