Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C

variables — concept C23

A variable is a declared object with a type, scope, and storage duration; an uninitialized automatic variable may hold an indeterminate value whose read can be undefined. Initialize before first read and keep scope narrow.

Version: C23

Syntax

variables

A variable is a declared object with a type, scope, and storage duration; an uninitialized automatic variable may hold an indeterminate value whose read can be undefined. Initialize before first read and keep scope narrow.

Initialize a variable at its declaration near first use and give it a name that states the unit, such as byte_count. When a function is to provide the value, assign it only after success or keep a separate initialization status.

Static objects without an explicit initializer are zero-initialized, but automatic objects have no such guarantee. Partial aggregate initialization zeros remaining members, while volatile means special observable accesses, not atomicity, locking, or safe sharing between threads.

Examples

#include <stdio.h>

int main(void) { int count = 2; count += 5; printf("%d\n", count); return 0; }

Result

7

A variable is a declared object with a type, scope, and storage duration; an uninitialized automatic variable may hold an indeterminate value whose read can be undefined. Initialize before first read and keep scope narrow.

Sources