A Quick Review of Structs
In C and other languages a structure (ie struct) is used to group
pieces of related data of different types into a single entity.
For example, a DayOfYear might be made up of two integers representing
the month and day.
struct DayOfYear
{
int month; /* 1 = Jan ... 12 = Dec */
int day;
};
The identifiers inside the brackets ( month, day ) are called
member names or simply members.
When a structure variable is declared, the value of each member can
be accessed using the dot notation as seen below
DayOfYear july4th;
july4th.month = 7;
july4th.day = 4;
- Any member of any structure variable may be changed by any code
that has access to the structure variable.
- Structs may be used as parameters to function.
- Functions may return structs.
- Structs may be used as members of other structs
- Structs contain only data members.
Last Modified: Monday, 28-Aug-2006 10:15:53 EDT