float x;
for (int i = 0; i < NUM_ITEMS; i++)
{
if (strcmp(tolower(item), tolower(menu[i].item)) == 0)
{
x = menu[i].price;
break;
}
}
I'm trying to compare the item and menu[i].item by converting them both into lowercase
Before using a function always read the function description.
The function
toloweris declared the following wayAs you can see it returns an object of the type
intand in turn accepts integers. But it seems you are passing to the function strings (as character arrays or pointers).So the compiler issues the message.
Also the function
strcmpis declared likeThat is it expects pointers to char as arguments.
However in this if statement
instead of passing pointers to strings (to their first characters) to the function
strcmpyou are passing integers returned by the functiontolower.It seems you need to write yourself a function that compares two strings characters of which are converted to the low case. For example the function can look the following way
and then
Otherwise if objects with the name
itemhave typecharthen just writeOr if the variable
itemhas typecharandmenu[i].itemrepresents a string then you can write