Structure Arrays in C Programming
Array of Structures
- Say we have some 100 employees we cannot create 100 structures. For this we have arrays to be used.
- The array of structures are defined just like we define an array of variables.
- The array of structures are defined and the operations on them are performed like the usual array of other data types.
Syntax:
data-type array-name[size of array];
Take the example of students and its size is 100 it will be defined in the following manner:
struct student stud_list [100];
Accessing the elements of this array is done by the index of array like n[0], n[1] etc. but the elements of this array are the structures and each member of the structure is accessed by the
'.' operator.
Syntax: To access the elements
array-name[index].member-name;
Example: Access the fees of the 4th student
student[3].fees;