Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Think back to the DVD-tracking program we've been discussing throughout this chapter. We started off with three separate arrays, each of which tracked a separate element. One array stored the rating field, another stored the movie's title, and the third stored a pithy comment.
We then introduced the concept of a structure that would group all the elements of one DVD together, in a single struct. One advantage of a struct is that you can pass all the information about a DVD using a single pointer. Imagine a routine called PrintDVD(), designed to print the three elements that describe a single DVD. Using the original array-based model, we'd have to pass three parameters to PrintDVD():
void PrintDVD( char rating, char *title, char *comment ) {
printf( "rating: %d\n", rating );
printf( "title: %s\n", title );
printf( "comment: %s\n", comment );
}