Posted in All Posts, Semester 2

Arrays of Structures

Welcome back! Previously we learnt about Structure syntax in C. Now we will learn about Arrays of Structures.

Arrays of Structures

We use structures to describe the format of a number of related variables. Like we may use a structure to describe student name and marks obtained by students

and then declare all students as structure variables.
For example, struct class student[100]; defines an array called student, that consists of 100 elements. Each element is of type struct class.
Consider the following example,

As you saw, to access the member variables through the structure variable array, we used [] with the desired index in the square brackets.
Like if we need to access the marks of subject 1 of the second student, then we have to write our code like this – student[1].sub1;

Arrays of Structures Example

Below is a program to demonstrate working of Array of Structures-

We hope that you found this article to be helpful.
Please share your thoughts in the Comments Section.

If you liked this article, then please like our Facebook page.

See Arrays within Structures.

Suggested Reading

One thought on “Arrays of Structures

Comment your thoughts

This site uses Akismet to reduce spam. Learn how your comment data is processed.