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 - C Tutorial
From the course: C: Data Structures, Pointers, and File Systems
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
Understanding arrays2m 59s
-
Working with arrays3m 5s
-
Modifying arrays3m 11s
-
Passing an array to a function3m 17s
-
Working multi-dimensional arrays3m 2s
-
Building a structure3m 23s
-
Nesting structures2m 56s
-
Creating an array of structures2m 28s
-
Sending a structure to a function3m 36s
-
Understanding a union2m 47s
-
Challenge: Presidents of the U.S.A.1m 38s
-
Solution: Presidents of the U.S.A.2m 52s
-
-
-
-
-
-