Hello, guys!
I have the following code:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct list_word
{
char word[64];
struct list_word * next;
};
typedef struct list_word itemWord;
int main()
{
itemWord * curr, * head;
fill list with words
[B]remove duplicates[/B]
show final list of words
return(0);
}
So I experience difficulties when implementing the removing duplicates part. What I tried to do is: get (each) word from list, strcmpit to next words, remove if duplicate found. Here is my solution:
curr = head;
while(curr)
{
strcpy(check,curr->word);
curr = curr->next;
while(curr)
{
if(strcmp(check,curr->word)==0)
printf("duplicate"); {here should come the remove node function}
curr = curr->next;
}
}
But something is wrong. It compiles without errors, but doesn't say anything about duplicates, even though I know there are. Thanks in advance!