Posted in All Posts, Semester 2

Arrays within Structures

C permits use of arrays are structure members. We have already learnt how to use Arrays of Structures. Similarly, we can use single-dimension or multi-dimensional arrays of type int or float as member variables in a structure. Let’s see how to declare Arrays within Structures.

Declaring Arrays within Structures

For example, the following structure declaration is valid.

Accessing Arrays within Structures

Here, the member sub contains three elements, sub[0], sub[1] and sub[2].
Now, student[1].sub[2]; will refer to the marks obtained by the second student in the third subject.

Arrays within Structures Example

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 Structures within Structures.

Suggested Reading

Comment your thoughts

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