Accessing Structure Members

Introduction :
  1. Array elements are accessed using the Subscript variable , Similarly Structure members are accessed using dot [.] operator.
  2. (.) is called as "Structure member Operator".
  3. Use this Operator in between "Structure name" & "member name"
struct Vehicle
{
int wheels;
char vname[20];
char color[10];
}v1 = {4,"Nano","Red"};
-- -- -- --
-- -- -- --
-- -- -- --
void main()
{
printf("Vehicle No of Wheels : %d",v1.wheels);
printf("Vehicle Name  : %s",v1.vname);
printf("Vehicle Color : %s",v1.color);
} 
Output :
Vehicle No of Wheels : 4
Vehicle Name  : Nano
Vehicle Color : Red
Note :
  • Dot operator has Highest Priority than unary,arithmetic,relational,logical Operators 

Bookmark & Share


Tags / Keywords : | ,

0 comments

Post a Comment

Your Feedback :This is Growing Site and Your Feedback is important for Us to improve the Site performance & Quality of Content.Feel Free to contact and Please Provide Name & Contact Email