A structure is a collection of variables of the same or different types under a single name.
In real life, we usually deal with entities that are collections of things, each thing having its own attributes. For example, a book is an entity with a collection of things, such as title, author, call number, publisher, number of pages, date of publication, etc.
All this data is dissimilar — the author is a string, whereas the number of pages is an integer. For dealing with such data, C provides a structure data type.
Structures can be declared in the following manner:
Structures can be used in the following manner:
struct structure_Name s1;
What to expect
This chapter presents numerous detailed examples on structures that will allow you to understand this important part of C programming.