`register` — C Keyword
`register` — C Keyword
The register keyword in C: hints that a variable should be kept in a CPU register.
`register` — C Keyword
The register keyword in C: hints that a variable should be kept in a CPU register.
Use reference pages to confirm names, categories, nearby facilities, and the constraints that matter before writing or reviewing code.
register (C)A storage class specifier that hints to the compiler that the variable should be kept in a CPU register for fast access. Taking the address of a register variable is not allowed.
register Type name;
#include <stdio.h>
long sum_array(const int* arr, int n) {
register long sum = 0;
for (register int i = 0; i < n; ++i) {
sum += arr[i];
}
return sum;
}
int main(void) {
int data[] = {1, 2, 3, 4, 5};
printf("%ld\n", sum_array(data, 5)); /* 15 */
register int x = 10;
/* int* p = &x; -- error: cannot take address of register variable */
return 0;
}
register as an optimization hint entirely.register was deprecated and removed as a keyword in C23.int main() {
// Pick one facility from this reference page.
// Write the smallest program that exercises its main precondition,
// complexity rule, or lifetime constraint before scaling up.
return 0;
}