The meaning of structure is the quality of being organized in general term. To understand the structure in programming language you must be able to link it with general meaning
1) How can we link it with general meaning? 2) What is structure in c?
In programming structure is the collection of various data of different data type. We can connect it with the class of java or other OOP language. As class has object which have property and method, But here we have an object and its property or value.
Structure helps to bring real physical object into virtual computer world.
A simple structure can be
Student with property
- Roll number
- Age etc.
1) How structure is different from array and variable? 2) What is advantage of structure?
Structure is used for data handling operation.
It can be good to think that there are already other syntax that can handle data, then why is the need of Structure.
The main advantage of structure is that it can group different types of logically related data .
For example if you want to create a record of a person that contains name, age and height of that person, then we can’t use array because all the three data elements are of different data types.
To store these related fields of different data types we can use a structure, which is capable of storing heterogeneous data.
Data of different types can be grouped together under a single name using structure.
The data elements of a structure are referred to as member (property)