Hey ya'll, I'm having an issue with my search function, which is supposed to search a linked list for a value the user enters. I seem to have trouble with my loop termination.
I keep hitting an endless loop so I believe it the while loop doesn't terminate when it's supposed to. I know it has something to do with the currentNode->next, but I have yet to wrap my head around the whole linked list concept.
Briefly: The linked list is a series of nodes, where each node connects to the next node.
At the very end of the linked list, the currentNode->next will be nullptr.
As your code currently is, if line 9 is true, then it will be true forever, because the else branch will never be hit again.
Make sure that each node is being created correctly such that the node->next member is nullptr unless assigned to be another node pointer.
Since you found the matching color, you can simply replace line 12 with "return;".