Nested Struct in C
Level 4201 keystrokes
Demonstrates nested structures where one struct contains another as a member.
C code
// Define Address structure1struct Address {2 char city[20];3 int zip;4};// Person contains Address as nested struct5struct Person {6 char name[20];7 struct Address addr;8};9 // The inner {} initializes the addr member10struct Person p = {"Alice", {"Tokyo", 1000}};// Chain dots to reach nested members: prints Alice, Tokyo 100011printf("%s, %s %d\n", p.name, p.addr.city, p.addr.zip);Output
Alice, Tokyo 1000
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this C code and how often they appear.
;× 8,× 6"× 6.× 5{× 4}× 4%× 3[× 2]× 2(× 1