I'm trying to make this basic 'MUD' style game to practice coding, the problem I was having was trying to have two structure types, each of which can contain a pointer to the other type. After I finally got that to compile via the forward typedef declarations, I can no longer access the structure elements and instead get the error: dereferencing pointer to incomplete type
Here is the code giving me the errors:Code:typedef struct node Items; typedef struct node Areas; struct Areas{ char desc[255]; char name[255]; Items*items; int n,s,w,e,u,d; }; extern struct Areas a[1000]; struct Items{ char*desc; char*name; Areas*loc; Items*next; Items*prev; };
I thought this might fix it, but no luck:Code:Items*new=createitem("NULL", "NULL", currentarea); name=strtok(input,","); new->name=name; desc=strtok(NULL, " "); new->desc=desc; if (a[currentarea].items!=NULL){ new->next=a[currentarea].items; a[currentarea].items->prev=new; a[currentarea].items=new;}
-Adam RinkleffCode:typedef struct items Items; typedef struct areas Areas;



LinkBack URL
About LinkBacks



