pointers - Removing duplicates in linked list in C doesn't work -


so i'm trying remove duplicates linked list , code doesn't work. input list of words, , print same list before , after "removing". please

typedef struct node {     char data[50];     struct node *next; } *list;  void removeduplicate(list words){     list o = null, t = null, d = null;     o = words;      while(o != null && o->next != null){         t = o;         while(t->next != null){             if(o->data == t->next->data){                 d = t->next;                 t->next = d->next->next;                 free(d);             }             else{                 t = t->next;             }         }         o = o->next;     } } 

you can't if(o->data == t->next->data) pointers starting location of char array , different. try using strcmp().


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -