What is wrong with the following search program for finding the node on List L, containing the airport code A and returning a pointer to it?
Code:
NodeType *FindNode(char *A, NodeType *L)
{
while ((strcmp(L->Airport,A)!=0) && (L!=NULL))
{
L=L->Link;
}
return L;
}
I have been at this for a while and can't figure out the problem. It seems fine to me. If the Airport codes do not match and the next node is not NULL, it advances to the next node within the while loop, until it finds a match. If the list is empty, or if there are no matches it will exit the loop and return NULL. Any hints as to what is wrong with this code would be appreciated.