VOOZH about

URL: https://www.geeksforgeeks.org/c/how-to-iterate-through-array-of-structs-in-c/

⇱ How to Iterate Through Array of Structs in C? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to Iterate Through Array of Structs in C?

Last Updated : 23 Jul, 2025

In C, while working with an array of structs we have to iterate through each struct in an array to perform certain operations or access its members. In this article, we will learn how to iterate through an array of the structs in C.

Iterate Over of an Array of Structures

To iterate through an array of the structures in C, we can simply use a loop (for loop or a while loop) and access each struct in the array using the array indexing, and then we can access every member using the member name.

C Program to Iterate Over an Array of Structs

The below example demonstrates how we can iterate through an array of structs and access each struct in C.


Output
Person Id: 1, Name: Ram, Age: 20
Person Id: 2, Name: Mohan, Age: 25
Person Id: 3, Name: Ria, Age: 30

Time Complexity: O(N), here n is the number of elements in the array of structs.
Auxilliary Space: O(1)

Note: We can also use a pointer to iterate through the array and access each element's members using the arrow operator (->).



Comment