I hate to do that... but you are my hope.
I think I have the delete function, this is what I have:
Code:
void delete_patient(tpatient *ptr, char *name) {
tpatient *temp, *prev;
temp=first;
while (temp!=NULL) {
if (strcmp(temp->name_patient,name)==0) {
if(temp==first) {
first=temp->next;
free(temp);
return;
} else {
prev->next=temp->next;
free(temp);
return;
}
} else {
prev=temp;
temp=temp->next;
}
}
}
In the menu, in int main () I have:
Code:
tpatient *ptr=patients;
char name[40];
case 'E':
printf("Insert the name to delete: ");
scanf("%s", name);
if (delete_patient(name)) {
printf("The patient %s has been removed", name);
} else {
printf("The patient %s is not in the list", name);
}
/*if (p==NULL) {
printf("\nPatient not found");
} else {
delete_patient(patients, name);
}*/
break;
In if (delete_patient(name)) I get:
Code:
error: cannot convert 'char*' to 'tpatient* {aka patient*}' for argument '1' to 'void delete_patient(tpatient*, char*)'|
Do you know how can I fix this? Why is complaining?