structure definition

Example by: Ira Oldham, References: Savitch eighth edition, section 10.1; Gaddis seventh edition, section 11.2

An variable of type int can contain one integer. An array of type int can contain a specified number of integers. A structure can contain data of different types. We must define what types of data will be used in the structure.

1  const int SIZE = 3;

2  struct Student
3  {
4    int id;
5    char grade;
6  };

7  int main()
8  {
9    int a;
10   int b[SIZE];
11   Student c;
12   return 0;
13 }

Student is defined as a structure type containg two members, one int and one char. c is a structure of type Student, containing one int and one char.