Array
Try it yourself →Fixed-size collection of elements.
Syntax
type name[size] = {e1, e2, ...};Description
Arrays have a fixed size. Elements are accessed by index starting from 0. C does NOT do bounds checking.
Example
#include <stdio.h>
int main() {
int numbers[3] = {10, 20, 30};
printf("%d\n", numbers[0]);
printf("%d\n", numbers[2]);
return 0;
}Expected output
10 30
When to use?
Fixed number of values.
Common mistakes
- ⚠️ Exceeding array bounds (numbers[5]) is undefined behavior; C does not warn you.