[prev] 86 [next]

typedef and struct (cont)

Note: structures can be defined in two different styles:

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

// or

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

The definitions produce objects with identical structures.

It is possible to combine both using the same identifier

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