pointer to struct in struct in c -


i have trouble structures in c.

i have 2 structures like

typedef struct {     char isim[256];     int deger;     struct ekstra *sonra; }ekstra;  typedef struct {     char *name;     int val;     struct ekstra *next; }node;  /*and main is*/  int main() {     int i;     node dizi[12];      for(i=0;i<12;i++)     {         dizi[i].name = malloc("asdasd"*sizeof(int));         strcpy (dizi[i].name,"asdasd");         /*and trouble starts here*/         **dizi[i].next = malloc(sizeof(ekstra));         printf("%s",dizi[i].next->isim);**     }  } 

the error is

error: dereferencing pointer incomplete type

how can hold place dizi[i].next?

struct ekstra not same ekstra.

your first struct typedef should declared follows:

typedef struct ekstra {     char isim[256];     int deger;     struct ekstra *sonra; }ekstra; 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -