> if(strcmp(head->data.name,name) == 0)
Hm, maybe you want to be comparing the name with the current node instead of 'head' each iteration?
John A
Vampirical Lurker
7,630 posts since Apr 2006
Reputation Points: 2,240
Solved Threads: 339
>Do you mean like this?
Well yeah, if searching through the linked list is your intention...
Another problem with your code: head is never assigned anything. There's no way your code is going to work unless you somehow give it a value.
[edit] Nevermind, I see now that 'head' is a class member, not a local variable. [/edit]
John A
Vampirical Lurker
7,630 posts since Apr 2006
Reputation Points: 2,240
Solved Threads: 339
How come on this line:
bool FoodList::searchByName(char name[],Food& foodItem)const
you used the [] after the name and not these ?()
That meansname is to be used as an array in the function.
Joe head is asigned to a NULL. Does NULL mean is a empty paramiter?
Yes.
WaltP
Posting Sage w/ dash of thyme
10,492 posts since May 2006
Reputation Points: 3,348
Solved Threads: 943