From the course: C: Data Structures, Pointers, and File Systems
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Solution: Presidents of the U.S.A. - C Tutorial
From the course: C: Data Structures, Pointers, and File Systems
Solution: Presidents of the U.S.A.
(funky techno music) - [Instructor] Here is my solution, which comes in three parts. First required are these structure definitions, they must be in this order. Date first, at line three, it contains three structure members, month, day, and year. Then comes the person structure at line eight, and it contains two members, a name string, and then the date structure tookoffice. This order works because the date structure is already defined in the source code, and these structures are declared externally so that all functions in this file fully recognize them. The main function creates the presidents array with four elements. Now, here, I've preset the values, organized across several lines. One set of braces collects all four elements in the array. Then braces enclose each element, which are the individual structures, in the array. And then within the structures themselves, you see the date structure member which is enclosed in braces again. A person structure temp is also created at…
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
-
(Locked)
Working with arrays3m 5s
-
(Locked)
Modifying arrays3m 11s
-
(Locked)
Passing an array to a function3m 17s
-
(Locked)
Working multi-dimensional arrays3m 2s
-
(Locked)
Building a structure3m 23s
-
(Locked)
Nesting structures2m 56s
-
(Locked)
Creating an array of structures2m 28s
-
(Locked)
Sending a structure to a function3m 36s
-
(Locked)
Understanding a union2m 47s
-
(Locked)
Challenge: Presidents of the U.S.A.1m 38s
-
(Locked)
Solution: Presidents of the U.S.A.2m 52s
-
-
-
-
-
-