There is no difference as such. typedef
just creates alias of a present datatype.
However, in first case you can declare the struct
variables as Person me;
, i.e. using Person
only. In second case you can either use Person me;
or struct Person me;
both are valid.
I find latter one more readable and understandable.
Extra Notes:
BTW your second declaration has a minor syntactic error:
struct Person
{
char *name;
int age;
}; // You missed this ';'
typedef struct Person Person;
You can also combine these two statements as:
typedef struct Person
{
char *name;
int age;
}
Person;