Advertisement

Question about C

Started by January 07, 2003 05:53 PM
7 comments, last by robirt 21 years, 10 months ago
I am trying to make a typedef struct like this typedef struct { NODE* child; NODE* parent; NODE* next; int nParents; BOOL visible; }NODE; but obviously i cant refer to NODE before it is declared. is there anything i can put before the struct so it will know i am going to declare NODE eventually. I am used to c++ where i can just do struct NODE { NODE* child; NODE* parent; NODE* next; int nParents; BOOL visible; }; and it works fine. but i have to use c for what i am doing, so please help. thanks in advance.
Rodger

  struct NODE;void Func(struct NODE *);typedef struct NODE {    int Magic;} NODE;  



Advertisement
i need the NODE type to be used within the NODE struct. That code doesnt work for it.
Rodger
just put an int and cast it to (NODE *) when you need it.
I am no C programmer, but how about
typedef struct NODETYPE{  struct NODETYPE* next;} NODE; 
what do you mean by ''cast'' it as a (NODE *)?
Rodger
Advertisement
quote: Original post by robirt
what do you mean by ''cast'' it as a (NODE *)?

I suggest don''t do it this way. Follows Miserable''s way.
"after many years of singularity, i'm still searching on the event horizon"
maybe this

struct NODE
{
int somehting;
NODE *next;
}
Nothing to do, try complimenting someone, it will make you feel better!
Thanks all. i got it now.
Rodger

This topic is closed to new replies.

Advertisement