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

Setting Up the Structure Declaration

A structure declaration is the master plan that describes how a structure is put together. The declaration looks like this:

struct book {
    char title[MAXTITL];
    char author[MAXAUTL];
    float value;
} ;

This declaration describes a structure made up of two character arrays and one float variable. It does not create an actual data object, but it describes what constitutes such an object. (Occasionally, we'll refer to a structure declaration as a template because it outlines how data will be stored. If you've heard of templates in C++, that's a different use of the word.) Let's look at the details. First comes the keyword struct. It identifies what comes next as a structure. Next comes an optional tag—the word ...

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