> initializing structure variables in c ~ Online tutorial

initializing structure variables in c

initializing structure variables in c
Like any other datatype ,a structure variable can be initializes at compil time

Syntax:
main()

{

struct
{
datatype variable;

datatype variable1;

}

student ={60,70,90};

}

This assigns values 60 to student.variabel and 70,90 to student.variable2 .

there is a one to one correspondence between the member and their initializing values

initializing Variabel
struct st_record

{

int wt;

float ht;

}student1={60,70,90};

main()
{
structst_record sstudent2={53,170.60};

}

Explanation
1.1.the keyword struct

2.the structure tag name

3.List terminated semicolon

4.The assignment operator=

Rule of initializing variable
1.we cannot initialize individual member inside the structure template

2.The order of values enclosed in braces must matchthe order of member in

the structure definition

3.zero for integer and floating point number

4.'\0' for character and string




Please Give Us Your 1 Minute In Sharing This Post!
Please Give Us Your 1 Minute In Sharing This Post!
SOCIALIZE IT →
FOLLOW US →
SHARE IT →
Powered By: BloggerYard.Com

0 comments: