Oct 8, 2012 at 9:39pm UTC
I have a program that I am trying to determine if one of the input characters is an h, c, or i. Its using <iostream> and namespace std;
cout << "Enter account #, code and gallons used: ";
cin >> account, code, gallons;
if (code == h || code == c || code == i)
void (function i need to run)
else
cout << "Invalid code input" << endl << endl;
I can't seem to get the letters evaluated whatever I do, any help would be appreciated
Oct 8, 2012 at 9:44pm UTC
by cin >> account, code, gallons;
do you mean cin >> account >> code >> gallons;
also I think if (code == h || code == c || code == i)
should be if (code == 'h' || code == 'c' || code == 'i' )
Oct 8, 2012 at 9:55pm UTC
I had code as type char, I did not have the single quotes and had the input formatting wrong. Didn't do cin >> account >> code >> gallons; the red lines have disappeared for now so hopefully it should run okay now. Thanks.