Structure :
Structure is the most important user defined data type in C. A structure is a collection of variables under a single name. These variables can be of different types, and each has a name which is used to select it from the structure. But in an array, all the data items are of same type. The individual variables in a structure are called member variables. A structure is a convenient way of grouping several pieces of related information together.
Declaration of a structure
Here's the most used example of structure for a student information like the following example:- struct student
- {
- char name[25];
- char faculty_Name[20];
- int age;
- int reg;
- };
We can also declare an another variable for struct.
Like
struct student StudentDetail;
Declaration of a structure always begins with the key word struct followed by a user given name, here the student.
So, we can use different types data and also store them in an array in the structure. And finally, full item will works as a unit which we can use afterwards.
No comments:
Post a Comment