Please help, I dont know what I am doing wrong and I been messing with this for 3 hours now.
Keep getting
Code:
error C2784: 'bool std:perator >(const std::basic_string<_Elem,_Traits,_Alloc> &,const _Elem *)' : could not deduce template argument for 'const _Elem *' from 'int'
/* Write a program that allows the user to enter foods and their calories. Allow for UP TO
100 entries, although the actual number may be way less. When the user types "done"
then stop asking for new entries. Prompt the user for a food item; when entered, search
the list and display the item and the number of calories. If the item is not found, indicate
that. Stop prompting for items to search for when the user enters "done". Use the
following screen shots as a guide.
*/
#include <iostream>
#include <string>
using namespace std;
int main()
{
string food[101];
int calories[101];
int a = -1;
do
{
a++;
cout << "Enter a menu item (enter 'done' when finished): ";
getline(cin, food[a]);
if (food[a] != "done")
{
cout << "Enter the number of calories: ";
cin >> calories[a];
cin.ignore();
}
} while (food[a] != "done");
for (int x = 1; x < a; x++)
{
for (int y = 0; y < a-1; y++)
{
if (food[y] > calories[x])
{
string tmpfood = food[x];
int tmpcalories = calories[x];
food[x] = food[y];
calories[x] = calories[y];
food[y] = tmpfood;
calories[y] = tmpcalories;
}
}
}
for (int b = 0; b < a; b++)
{
cout << food[b] << " has " << calories[b] <<
" calories." << endl;
}
}