c / beginner
Snippet
Accessing 2D Array Elements
Two-dimensional arrays use two indices: the first for the row and the second for the column.
snippet.c
1
2
int grid[2][3];grid[1][2] = 50;
Breakdown
1
grid[2][3]
Declares a 2D array with 2 rows and 3 columns.
2
grid[1][2]
Accesses the element at the second row (index 1) and third column (index 2).