I do have 2 structures here. main linked list is the word. each node of the word list do have a meaning
typedef struct node{
char word[20];
struct node2 *meaning;
struct node *next;
}word;
typedef struct node2{
char meaning[100];
struct node2 *next;
}means;
My problem now is I can't add multiple meanings. I can just add 1 meaning and whenever i try to add, it overwrites the previous meaning instead., how can i do this? this is how i add meaning
word *tmp2=(*head);
means *tmp3;
tmp3=(means *)malloc(sizeof(means));
if(tmp2==NULL){
printf("\n**List still empty, add a word**\n");
return;
}
do{
if(strcmp(tmp2->word,ins)==0){
tmp2->meaning=tmp3;
strcpy(tmp3->meaning,mea);
tmp3->next=NULL;
printf("\n**You have successfully added a meaning**\n");
return;
}
tmp2=tmp2->next;
}while(tmp2!=NULL);
printf("\n**Word is not on the list, cannot add meaning**\n");
return;