Structures are used more in C than 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. A structure is a convenient way of grouping several pieces of related information together.
A structure can be defined as a new named type, thus extending the number of available types. It can use other structures, arrays or pointers as some of its members.
A structure is similar to a class,but in a class you can specify your data and functions as "private","protected" or "public".However in a structure all data and functions are private.Since having functions as private would serve no purpose(as they wouldn't be accesible from outside the structure).
For a very good tutorial on structures in C click >>>Here<<< .
The following program is available:
- A program to define a Structure time and add and subtract two times.
|