From the course: C: Data Structures, Pointers, and File Systems

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Working multi-dimensional arrays

Working multi-dimensional arrays - C Tutorial

From the course: C: Data Structures, Pointers, and File Systems

Start my 1-month free trial

Working multi-dimensional arrays

- [Instructor] Most arrays are linear, but they can branch out into other dimensions as well. For example, in this code, you see a two dimensional array, which works like a table with rows and columns. The array is declared at line five. It can be read as a matrix of five rows by two columns or five columns by two rows. The array's elements must also be referenced by using the same dimensions. At lines 10 and 11, you see two sets of brackets that refer to elements, X, and elements, zero and one. The same bracket pairs are used on line 15 as well. Build and run and here you see the table. The multi-dimensional array in this code generates a three by three matrix. The character array, tictactoe, declared at line five, is two dimensional with three elements in each dimension, or three rows of three columns, essentially a grid or matrix. Nested loops, starting at line nine, fill the grid with period characters. A second set…

Contents