我很难弄清楚为什么我的删除功能不起作用。它是一个布尔值,如果项目被删除,则需要返回。任何帮助,将不胜感激
boolean delete(SLL *list, String str){
NODE *current, *previous,*temp;
temp=malloc(sizeof(Employee));
previous=NULL;
current = list -> head;
while(current->next!=NULL) {
if(strcmp(current->anEmployee->name, str) == 0){
if(current=list->head){
list->head=current->next;
}
if(previous->next == NULL){//item not found in list
return 0;
}
else { //current is to be deleted
temp->next=current->next;
previous->next=temp->next;
return 1;
}
}
}