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
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;
};
Here is the code giving me the errors:
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;}
I thought this might fix it, but no luck:
Code:
typedef struct items Items;
typedef struct areas Areas;
-Adam Rinkleff