Breaking News

Structure Initialization

a structure variable can be initialization as any other data type.

Main()
{
static struct
{
int weight;
float height;
}
}
student{560,080,75};

This assign the value 60 to student weight and 180.75 student height. there is a one to one correspondents between the members and their initializing values.

The following statements initialize two structures variables:

Main()
Struct st_decord
{
int weight;
float height;
}
static struct st_record student2={53, 170,60}
}

another method is to initlialize a structure variable outside the function.

Struct st_record/* No static word*/
{
int weight;
int height
}
student={60,50,75}
}
main()
{
static struct st_record student2={53,170,60}

Check Also

Type modifier In C Programming Language

The basic data types may have modifier preceding them to indicate special properties of the object being …