C Structures
Structures in C allow you to store data of different types. You can easily store variables of types, such as int, float, char, etc. For example, storing the details of employees, with the following members:
- name: string type
- age: int type
- zone: string type
- salary: float type
Now, you would be wondering about the difference between structure and arrays. Well, Arrays stores data of similar types, for example, an array of ints, whereas Structure stores data of different types.
Define a Structure
Let us understand the above concept with an example to define a structure. To define a structure, use the struct keyword:
0 comments:
Post a Comment