Loading lessons...
C Cheatsheet: Data Types
Cheatsheet: Core Data Types
The tables you keep Googling, in one place.
Integers
| Type | Typical size | Range |
|---|---|---|
| int | 4 bytes | ~ -2.1 billion to +2.1 billion |
| char | 1 byte | -128 to 127 |
| short | 2 bytes | ~ -32,768 to 32,767 |
| long | 4 or 8 bytes | platform dependent |
Floats
| Type | Size | What it's for |
|---|---|---|
| float | 4 | small decimals |
| double | 8 | default, precise |
Note
int may give an easy breakdown across platforms; use <stdint.h> for exact sizes (int32_t, uint8_t) when it matters.
TL;DR
- int = 4 typical. char = 1. double = 8.
- Ranges vary by platform.
- Use <stdint.h> types for guaranteed sizes.