O'Reilly logo

C Primer Plus, Fourth Edition by Stephen Prata

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Nested Structures

Sometimes it is convenient for one structure to contain, or nest, another. For example, Shalala Pirosky is building a structure of information about her friends. One member of the structure, naturally enough, is the friend's name. The name, however, can be represented by a structure itself, with separate entries for first and last name members. Listing 14.3 is a condensed example of Shalala's work.

Listing 14.3. The friend.c Program
 // friend.c -- example of a nested structure #include <stdio.h> #define LEN 20 const char * msgs[5] = { " Thank you for the wonderful evening, ", "You certainly prove that a ", "is a special kind of guy. We must get together", "over a delicious ", " and have a few laughs" } ; struct names { // first ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required