Overview of C 37
1.13.4 Initializing Structures
When a structure variable is declared, its data members are not initialized and, therefore, contain unde-
fined values. Similar to arrays, the structure variables can also be initialized. For instance, the structure
shown in Figure 1.10 can be declared and initialized as shown below:
struct student
{
char name[20];
int age;
int roll;
char class[5];
};
/* Initialize variable of type student*/
struct student stud1 = {“SACHIN KUMAR”, 18, 10196,” CE41”};
Please notice that the values are enclosed within curly braces. The values are assigned to the mem-
bers of the structure ...