C
chellappa
hi Everybody!
i am trying multiple array linked list .. i am trying , but its give
derefernceing pointer to incompelete type .. please help me to correct
this pgm
#include<stdlib.h>
#include<stdio.h>
void insert(int listno,int value);
struct listl {
int val;
struct list * next;
};
typedef struct list item;
item * curr[10], * head[10];
int main(void) {
int i;
for(i=0;i<=9;i++)
{
head = NULL;
}
insert(2,21);
insert(2,2);
insert(2,5);
insert(7,54);
insert(7,45);
insert(7,75);
curr[2] = head[2];
curr[7] = head[7];
while(curr[2]&&curr[7])
{
printf("%d\n%d\n", curr[2]->val,curr[7]->val);
curr[2] = curr[2]->next ;
curr[7] = curr[7]->next ;
}
}
void insert (int listno,int value)
{
curr[listno] = (item *)malloc(sizeof(item));
curr[listno]->val = value;
curr[listno]->next = head[listno];
head[listno] = curr[listno];
}
Thnank u
by
CNS
i am trying multiple array linked list .. i am trying , but its give
derefernceing pointer to incompelete type .. please help me to correct
this pgm
#include<stdlib.h>
#include<stdio.h>
void insert(int listno,int value);
struct listl {
int val;
struct list * next;
};
typedef struct list item;
item * curr[10], * head[10];
int main(void) {
int i;
for(i=0;i<=9;i++)
{
head = NULL;
}
insert(2,21);
insert(2,2);
insert(2,5);
insert(7,54);
insert(7,45);
insert(7,75);
curr[2] = head[2];
curr[7] = head[7];
while(curr[2]&&curr[7])
{
printf("%d\n%d\n", curr[2]->val,curr[7]->val);
curr[2] = curr[2]->next ;
curr[7] = curr[7]->next ;
}
}
void insert (int listno,int value)
{
curr[listno] = (item *)malloc(sizeof(item));
curr[listno]->val = value;
curr[listno]->next = head[listno];
head[listno] = curr[listno];
}
Thnank u
by
CNS