C StructuresLesson 36Free preview
C Nested Structures
This lesson is part of C · All levels
Summary
A nested structure is a structure that has members that are other structures, so that data can be organized in layers. The access is done in a sequence with a point, e.g. sekolah.alamat.city, which reflects the hierarchical relationship of the data. This pattern is useful for complex data such as addresses consisting of streets, cities, and countries, or repetition of elements such as a list of values in a single student. With proper division, data structures become easier to understand and reuse.
Key points
- Nested struct is a struct in which there are members of other struct types.
- Access members are nested using a point chain such as obj.field.subfield
- The inner struct type can be reused on many other structures.
- The layered structural division reflects the hierarchy of data naturally.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.