Possible Duplicate:
Difference between 'struct' and 'typedef struct' in C++?
what is the difference between:
struct a{
...
}
and
typedef struct{
...
} a;
?
Possible Duplicate:
Difference between 'struct' and 'typedef struct' in C++?
what is the difference between:
struct a{
...
}
and
typedef struct{
...
} a;
?
In C++, there is no difference. In C, however, use of
struct a { ... };
Requires you to use the following to declare variables:
int main ( int, char ** )
{
struct a instance;
}
To avoid the redundant struct
in variable declarations, use of the aforementioned typedef
is required and allows you to use only the a instance;
syntax
In the first to declare you must say struct a my_struct;
in the latter you simply say a my_struct;