C Basics · beginner · ~10 min
Pick the right primitive type for the data at hand.
C's built-in types fall into a few groups:
char, short, int, long, long long plus unsigned variants. Sizes are platform-dependent; use <stdint.h> (int32_t, uint64_t) when you need exact widths.float (32-bit), double (64-bit), long double (larger, varies)._Bool (or bool after #include <stdbool.h>), with true / false.void for "no value" (e.g., a function returning nothing).#include <stdint.h>
#include <stdbool.h>
uint32_t pixels = 1024 * 768;
bool enabled = true;
double ratio = pixels / 2.0;
int is 32 bits everywhere — it usually is, but not on every platform.-1 < 1U is false because of integer promotion).