Help me fix the code please.
The program works correctly, but after displaying the desired item just hangs.
void find() { car *p, *temp; char sp[10]; clrscr(); printf("Vvedite model' mashini,kotoruiu hotite naiti: "); scanf("%s", &sp); p = head; while (p == NULL) { if(strcmp((p->model), sp) == 0) { printf("[Marka]\t[Model]\t[Cvet]\t[Strana]\t[Cena]\n"); printf("%s", p->marka); printf("\t%s\t", p->model); printf("%s\t", p->cvet); printf("%s", p->strana); printf("\t\t%s\n", p->cena); p = p->next; } } } I use Borland C 3.1, I write in C. Thank you in advance
strcmpreturns 0. Therefore, the loop after the found element is trampled in place. 30 seconds in the debugger would save you 5 minutes on registration and question wording. - VladD pmwhile (p==NULL)you need instead of==to write!=(Or justwhile (p) { ...or also stereotypicallyfor (; p; p = p->next) { ...- avpiftowhile? - adlop==NULLtop!=NULL, I just forgot to change it here. The problem is the same .. - adlo