what is the difference between
typedef struct {
type1 id_list1;
type2 id_list2;
.....
}struct_type;
and
struct struct_type{
type1 id_list1;
type2 id_list2;
.....
};
I am confused.
please explain it. Thank you
what is the difference between
typedef struct {
type1 id_list1;
type2 id_list2;
.....
}struct_type;
and
struct struct_type{
type1 id_list1;
type2 id_list2;
.....
};
I am confused.
please explain it. Thank you
If you declare your struct like this:
you can declare a struct variable like this:Code:typedef struct { type1 id_list1; type2 id_list2; ..... }struct_type;
If you declare you struct like this:Code:struct_type mytype;
you have to declare a struct variable like this:Code:struct struct_type{ type1 id_list1; type2 id_list2; ..... };
Code:struct struct_type mytype;
This defines a new data type called 'struct_type'. You use it like:Code:typedef struct { type1 id_list1; type2 id_list2; ..... }struct_type;
struct_type x;
This creates an instance of 'struct_type' called 'x'.
This defines a structure with a name. To use it, you use:Code:struct struct_type{ type1 id_list1; type2 id_list2; ..... };
struct struct_type x;
This creates an instance of a named structure, called 'x'.
[edit] Curses, foiled again! [/edit]
Quzah.
Hope is the first step on the road to disappointment.