Nearby lessons
61 of 72C - Nested Structures
A nested structure means one structure is used as a member inside another structure. For example, a student record can contain an address.
1. Example of a Nested Structure
Here, Address stores a city and a PIN code. The Student structure contains an Address member named address.
Example01
2. Understand the Dot Operator
s1.nameaccesses the student's name.s1.addressaccesses the address structure.s1.address.cityaccesses the city inside the address.s1.address.pinCodeaccesses the PIN code inside the address.
Common Mistakes
- Use the exact member names defined in both structures.
- Use a dot for each level of a nested structure.
- Make sure the inner structure type is defined before using it as a member.
📝 Key Takeaways
- A structure can contain another structure as a member.
- Use more than one dot to access a nested member.
- For example, student.address.city accesses the city inside the student address.
🧠 Test Your Knowledge
1 QuestionsProgress: 0 / 1