Computer
Programming
Arrays of structures
An array of structures is defined like:
struct personal_data my_struct_array[100];
The members of the structures in the array are then accessed by statements such as the following:
The value of a member of a structure in an array can be assigned to another variable, or the value of a variable can be assigned to a member.
For example, the following code assigns the number 1965 to the year_of_birth member of the fourth element of my_struct_array:
my_struct_array[3].year_of_birth = 1965;
The following code assigns the value of the year_of_birth member of the fourth element of my_struct_array to the variable yob:
yob = my_struct_array[3].year_of_birth;
Finally, the following example assigns the values of all the members of the second element of my_struct_array, namely my_struct_array[1], to the third element, so my_struct_array[2] takes the overall value of my_struct_array[1].
my_struct_array[2] = my_struct_array[1];
The reference site for this content is http://cprogramminglanguage.net/c-structure.aspx




