Structutre in C

Structure

Structure is used for creating user defined data type. A structure gathers together different-different data type into a single entity. Using structure we can create a data type which can store some different type of value into a single variable. Draw back of variable is, it only stores one value at a time. C provides a structure which is used to create structure. The keyword is "struct".

Creating Structure in C:-

struct stu

{
           int r;
                        char n[20];
};

Few important point about structure:-

1- We use . (Period) operator to access member of structure.

2- We use -> to access member of structure through pointer.

3- Structure can be nested but can't contain itself variables.

4- Structure can contain itself pointer.
Next PostNewer Post Previous PostOlder Post Home