Structure is an user define data type which is collection of different primitive data types.
Syntax :
struct tagname
{
member 1;
member 2;
member 3;
.
.
.
};
- tagname is nothing but new data type;
- Until and unless we create a variable for structure there is no memory allocated for the member;
- If we want to access the member of structure through structure variable we use dot(.) operator;
- If we want to access the member of structure through structure pointer, we use arrow (->) operator;
Limitation of structure :-
- It is not possible to initialize the member of structure.
- Storage classes are not allowed for structure members but storage classes are allowed for variable of structure.
- In a structure we can't declare the same structure type but we can create a same structure pointer. (Self referential structure)
- Structure within structure is possible but the changed name (using typedef) structure is not possible in that structure.