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.

Solution: Presidents of the U.S.A. - C Tutorial

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

Start my 1-month free trial

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…

Contents