c / beginner
Snippet
Array Initialization
You can declare and initialize an array in one step using curly braces to list the starting values.
snippet.c
1
int levels[3] = {10, 20, 30};
Breakdown
1
int levels[3]
Declares an array of integers named 'levels' with a fixed size of 3.
2
{10, 20, 30}
Assigns 10 to index 0, 20 to index 1, and 30 to index 2 immediately.