Because a structure is a variable, it can also be included within another structure. To reference a nested structure's members, two dots are used: one for the nested structure and a second for the nested structure member. Multiple copies of a structure can be included within another structure, providing each is given a unique variable name.
- [Instructor] A structure can hold … any variable type as a member. … And this rule includes other structures, … what I call nested structures. … So in this exercise file, … you see two structures. … The first, … date, … holds three members, … integers month day and year. … The second, … person, … holds two members. … The first is a date structure referenced as birthday. … The second is a character array a string name. … See how the structure member at line 12 … is defined like any variable? … The struct keyword comes first, … then the structure definition date, … and then the variable name birthday. … At line 15, … a person structure variable, … president is declared. … Lines 17 through 20 fill the members … of the president structure variable. … For a nested structure two dots are used … to reference the inner member. … President.birthday refers to the birthday member, … and the .month refers to the month member … inside the nested structure. … At line 20 you see the string copy function used, …
- Working with arrays
- Building a structure
- Creating an array of structures
- Testing characters
- Working with strings in C
- Using pointers to manipulate data
- Manipulating files
- Using command-line arguments
- Working with time functions
Skill Level Intermediate
1. Arrays and Structures
2. Characters and Strings
4. Files and the Operating System
5. The Interesting and Extraordinary
Next steps1m 52s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.