Ok, here is the loop from my code, a for loop inside a do...while. The title is a tad misleading, I couldn't edit it though. Probably not the most efficient coding to do what I want but I have no errors and it is so close to working. When I recall an item that was previously entered into an array, the loop correctly finds the result and prints the correct message, but also prints the error message later on. It doesn't seem that the tmp variable should have been changed yet to mess with it, plus it fails when using "done" as well. The error message always is displayed.
do
{
string tmp = "";
cout << "Enter a product to look up: "; getline (cin, target);
for (int i = 0; i < x; i++)
{
if (food[i] == target)
{
tmp = target;
cout << target << " has " << cal[i] << "calories." << endl;
}
else
{
}
}
if ((tmp != target) || (target != "done"))
{
cout << target << " was not found." << endl;
}
else
{
}
} while (target != "done");