`auto` — C Keyword
`auto` — C Keyword
The auto keyword in C: a storage class specifier for automatic (stack) storage duration.
`auto` — C Keyword
The auto keyword in C: a storage class specifier for automatic (stack) storage duration.
Use reference pages to confirm names, categories, nearby facilities, and the constraints that matter before writing or reviewing code.
auto (C)Specifies automatic storage duration — the variable lives on the stack for the duration of its enclosing block. This is the default for local variables; the keyword is redundant and rarely written explicitly.
auto Type name;
auto Type name = initializer;
#include <stdio.h>
int main(void) {
auto int x = 42; /* same as: int x = 42; */
printf("%d\n", x);
{
auto int y = 10; /* y exists only inside this block */
printf("%d\n", y);
}
/* y is no longer accessible here */
return 0;
}
auto is a remnant of early C; in practice it is always implied for local variables.auto, which is type deduction — completely different meaning.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;
}