Nested structures in C - Printable Version +- QP School (https://qomplainerzschool.lima-city.de) +-- Forum: Tutorials (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=3) +--- Forum: C 18 Tutorials (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=32) +--- Thread: Nested structures in C (/showthread.php?tid=5096) |
Nested structures in C - Qomplainerz - 07-25-2023 Structures can be nested within each other. struct Address { char city[50]; char state[50]; }; struct Person { char name[50]; int age; struct Address address; }; int main() { struct Person p1; strcpy(p1.name, "John"); p1.age = 30; strcpy(p1.address.city, "New York"); strcpy(p1.address.state, "NY"); printf("Name: %s, Age: %d, City: %s, State: %s\n", p1.name, p1.age, p1.address.city, p1.address.state); return 0; } |