Nested Structs
Nested Structs

Just as we can group built-in data types in C together using a struct, we can group structs together within a struct.

Example:

struct book { char author[40]; char title[40]; int edition; int callNumber; float price; }; struct inventory { struct book current; struct book replacement; int datePurchased; };
Now in order to access the individual members of the struct: struct inventory fantasy; ... we use the "dot operator" as below: fantasy.current.author fantasy.replacement.price fantasy.datePurchased Any Questions???


Main Page
Last Modified 17 October 2000