But please note that the following initializations are invalid: struct Emp { char fname[10] = “Rajiv”; /* invalid */ int lname[10] = “Chopra”; /* invalid */ int age= 40; /* is invalid */ …… }; This means that individual members cannot be initialized inside the structure declaration. If you
do this, you will get a compilation error.
Array of Structures When we want to store a large number of similar records—say, of 100 employees—then an array of
structures is defined as follows:
struct Emp
{
char fname[40], lname[40];
int age;
float salary;
char address[30], dept[30];
};
struct Emp emp1[100]; /* declaring array of structures */
This means that emp1 is an array having 100 elements of type struct Employee.
It is after this statement only that the C compiler reserves memory space for 100 structures; the same rule applies for array of structures as for array of primary data types like ints, floats, or chars.