register keyword

The register keyword in C suggests that the variable should be stored in a CPU register instead of memory for faster access.

Usage

register int b = 2;

Limitation: It’s only a hint; the compiler can ignore it.

Optimization: Modern compilers often optimize better without register.

register also exists in C++, but in C++17 and onwards, register is deprecated.