[prev] 74 [next]

Sidetrack: Defining Structures

Structures can be defined in two different styles:

typedef struct { int day, month, year; } DateT;
// which would be used as
DateT somedate;

// or

struct date { int day, month, year; };
// which would be used as
struct date anotherdate;

The definitions produce objects with identical structures.

It is possible to combine both styles:

typedef struct date { int day, month, year; } DateT;
// which could be used as
DateT       date1, *dateptr1;
struct date date2, *dateptr2;