I've seen these two different styles in many places. So I'm wondering, whats the difference between these two?
Code:typedef struct { char *name; int id; } Tag;Code:struct Tag { char *name; int id; };
I've seen these two different styles in many places. So I'm wondering, whats the difference between these two?
Code:typedef struct { char *name; int id; } Tag;Code:struct Tag { char *name; int id; };
In the first case, you make a typed definition of the structure meaning you can use it as any datatype (when declaring, in arguments etc...).
In the second case, you need to specify the keyword 'struct' when declaring variables, which you don't do in the first case.
Other than that, I believe they are pretty much the same.
I usually typedef all my structs.
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.
Oh I see, thanks. Well it doesn't matter to me since I'm a C++ programmer!