Here is the piece of code I am having problems with. It is supposed to let me look up any items I put in the program previously. If the user did not enter a product earlier it should say "product not found".
My problem is that it remembers the first product I entered into the program, but any other entries I made after that aren't recognized and say "product not found".
Please help.
bool look = false;
do
{
cout << "Enter a product to look up: ";
getline (cin, search);
for (int y = 0; y < x; y++)
{
if (search == food[y])
{
cout << food[y] << " has " << calories[y] << " calories." << endl;
look = true;
}
if ((look == false) && (search != "done"))
{
cout << search << " was not found." << endl;
break;
}
}
}
while (search != "done");
}