how to check if string exists in a struct linked list?
can someone provide an example of a struct linked list, where it has strings as its values, and then how do I check if a specific string (say called buffer) exists in the list of structs?
i dont understand how to make a copy of it to check with
this is what i have
Code:
// CHECK IF ITEM EXISTS IN THE ITEM LIST
check=0; tmp_item_list=item_list;
while(tmp_item_list) {
if (strcmp(tmp_item_list->number,buffer)==0) {
tmp_buffer0[0]='\0';
strcat(tmp_buffer0,tmp_item_list->number);
strcat(tmp_buffer0," ");
strcat(tmp_buffer0,tmp_item_list->name);
strcat(tmp_buffer0," ");
strcat(tmp_buffer0,tmp_item_list->current_price);
strcat(tmp_buffer0,"\n");
send_message(i, tmp_buffer0); check=1; break;
}
tmp_item_list=tmp_item_list->next;
}
i want to make a copy because if i dont then
tmp_item_list=tmp_item_list->next;
will screw it up
also this wont work, because somehow when i iterate through the list, it seems the list repeats again...
this compiles fine with no errors/warnings