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

Defining a Structure Variable

The word structure is used in two senses. One is the sense “structure plan,” which is what we just discussed. The structure plan tells the compiler how to represent the data, but it doesn't make the computer allocate space for the data. The next step is to create a “structure variable,” the second sense of the word. The line in the program that causes a structure variable to be created is this:

struct book libry;

Seeing this instruction, the compiler creates the variable libry. Using the book template, the compiler allots space for a char array of MAXTITL elements, for a char array of MAXAUTL elements, and for a float variable. This storage is lumped together under the single name libry (see Figure 14.1). (The ...

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