From the course: C Essential Training

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Structures

Structures

- A structure is an aggregate of variables in C , it's a simple way of collecting a number of disparate variables in a single container. This is struct.cpp from chapter four of the exercise files. And here we define a simple structure that contains a few different types of variables. Variables in the structure are often called members or sometimes properties. This structure contains three members, an integer, a double and a C-string. The structure itself is simply the definition, it's very much like an aggregate type and it's used as a type in the code. Here, we define a variable or an object based on that structure. So the structure is type capital S and the object is S-one and we're initializing it with this initializer list which simply contains the three different values separated by commas, so the integer, I is three, the double D is 47.9 and the C-string S is string-one. Individual members of the structure are…

Contents