A one-dimensional array in C is a contiguous block of memory designed to store a fixed-size sequence of elements sharing a single data type. The array identifier represents the array object itself (of typeDocumentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
T[N]). It is not a pointer or a reference; rather, during most expression evaluations, the identifier implicitly decays into a pointer to its first element.
Declaration Syntax
To declare a one-dimensional array, specify the data type, the array identifier, and the total number of elements enclosed in square brackets[].
data_type: Determines the amount of memory allocated per element and how the bit patterns are interpreted (e.g.,int,char,float).array_size: Must be an integer constant expression greater than zero (excluding C99 Variable Length Arrays). This dictates the total memory footprint:array_size * sizeof(data_type).
Initialization
Arrays can be initialized at the point of declaration using an initializer list enclosed in braces{}.
Memory Layout and Indexing
C arrays are zero-indexed. The index represents the offset from the base address. Because the memory is strictly contiguous, the compiler calculates the exact memory address of any element in constant time using pointer arithmetic:Address of array[i] = Base_Address + (i * sizeof(data_type))
Access and Mutation
Elements are accessed and mutated using the subscript operator[]. Under the hood, array[i] is syntactic sugar for dereferencing a pointer offset: *(array + i).
Array-to-Pointer Decay
In most expressions, a one-dimensional array identifier “decays” into a pointer to its first element (&array[0]).
- When it is the operand of the
sizeofoperator (returns the total byte size of the array object). - When it is the operand of the
&(address-of) operator (returns a pointer to the entire array, e.g.,int (*)[5]). - When it is a string literal used to initialize a character array.
Bounds Checking
The C standard dictates that there is no implicit bounds checking on array accesses.0 to array_size - 1 results in Undefined Behavior, which typically manifests as memory corruption, segmentation faults, or silent data mutation in adjacent memory blocks.
Master C with Deep Grasping Methodology!Learn More





