i try understand c code:
typedef struct _intelem *intlist; typedef struct _intelem { int head; intlist tail;} intelem; i understand defines recursive type, list. don't understand way declared. understand second line, define structure named intelem consists of integer , intlist. _intelem in declaration?
the first line allocates memory list?
the first line
typedef struct _intelem *intlist;
is create typedef or alias struct _intelem *. alias named intlist. fwiw, @ point of time, definition of struct _intelem need not known compiler.
the second line
typedef struct _intelem { int head; intlist tail;} intelem;- actually defines user-defined type
_intelem, 2 members,headint,tailintlist(typedefed earlier) typedeftypeintelem.
- actually defines user-defined type
please note: there no variable created, either of type (s) (i'm not talking member variables, of course, part of definition). so, there no memory allocated , such.
so, explicit
but
_intelemin declaration?
the _intelem name of user-defined data type. however, in cases, optional. example,
typedef struct { char name [32]; int age; float salary;} employee; is both fine , legal, except fact, in case, we're creating alias employee unnamed data type.
Comments
Post a Comment