GuiccoPiano
GuiccoPiano

Reputation: 146

typedef in C difference?

What is the difference between the following in C language:

typedef enum month_t
{
jan,
feb,
march
}month;

AND

typedef enum
{
monday,
tuesday,
wednesday
}day;

Before posting this question I read this : What is a typedef enum in Objective-C?

But did not understand quite well...

Upvotes: 1

Views: 216

Answers (1)

unwind
unwind

Reputation: 399871

The first also introduces an enum tag, which means the enumeration can be used like this:

enum month_t first = jan;
/* or */
month second = feb;

the second doesn't, so the enumeration is only available with the typedef:ed name day.

Also, of course, the enumerations themselves are different, but that's kind of obvious.

Upvotes: 11

Related Questions