Declaring Structure Variable in C
Syntax :
Yet another Syntax :struct tag { member1; member2; member3; };
struct <structure_name> { structure Element1; structure Element2; structure Element3; ... ... };
Note
- Struct keyword is used to declare structure.
- Members of structure are enclosed within opening and closing braces.
- Declaration of Structure reserves no space.
- It is nothing but the " Template / Map / Shape " of the structure .
- Memory is created , very first time when the variable is created / Instance is created.
Ways of Declaring Structure Variable / Structure Instance :
Way 1 : Immediately after Structure Template
struct date { int date; char month[20]; int year; }today; // 'today' is name of Structure variable
Way 2 : Declare Variables using struct Keyword
struct date { int date; char month[20]; int year; }; struct date today; /*----------------------------------- date : Name of Structure today : Structure Variable ---------------------------------- */
Way 3 : Declaring Multiple Structure Variables
struct Book{ int pages; char name[20]; int year; }c,cpp,java; // Multiple Structure Variables


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