Declaring a Structure variable:
To access the members of structures a variable of structure type must be declared.
Method 1:
Syntax :
struct structure-name var-name1, var-name2, ..., var-nameN;
Example:
To declare a structure variable for Employee,
struct Employee e;
'e' is declared as structure variable of type Employee structure and using which one can access the members of structure Employee.
Method 2:
struct Employee
{
int Eid;
char ename[50];
char dname[50];
}e;
In second method, a variable 'e' is declared at end of structure of declaration.
To access the members of structures a variable of structure type must be declared.
Method 1:
Syntax :
struct structure-name var-name1, var-name2, ..., var-nameN;
Example:
To declare a structure variable for Employee,
struct Employee e;
'e' is declared as structure variable of type Employee structure and using which one can access the members of structure Employee.
Method 2:
struct Employee
{
int Eid;
char ename[50];
char dname[50];
}e;
In second method, a variable 'e' is declared at end of structure of declaration.
Comments
Post a Comment