Compiler error "character constant too long for its type". What's wrong?

As others have pointed out, you need to use double quotes ("y" instead of 'y') for your strings, otherwise they are character literals.

In C/C++, there is such a thing as a multi-character literal; its value is a number made up of somehow putting the character codes for the individual characters together in some implementation-defined way. You don't want to ever use them unless you have a really really good reason. They only reason you need to know about them is to understand the warnings and error messages:

test.cpp:19: error: no match for ‘operator==’ in ‘choice == 1919378802’

... means that there is no way to compare a string with the number 1919378802, which is what your compiler interprets 'hamburger' to mean.

Once that is fixed, your new error message:

.test.cpp:23: error: no match for ‘operator||’ in ...
.test.cpp:23: note: candidates are: operator||(bool, bool) <built-in>

means that something went wrong with one of the || operators. Maybe one of its operands wasn't actually a boolean expression. The "note" tells you that there is a built-in || for two bools, but that it couldn't be used in this situation.

Solution: Replace opt = 'Yes' by opt == "Yes".

The single =, assignment, means that the result of that expression is not a bool but a string, and there is no operator|| for or-ing a boolean with a string.

Style Note: It's usually considered better style to not use a using namespace std declaration. Instead, explicitly refer to standard library stuff (cout, endl, string, getline) using a std:: prefix, as in std::string.


You're using single quotes to enclose a string. You need to change

if (choice == 'hamburger' || choice == 'Hamburger')

to

if (choice == "hamburger" || choice == "Hamburger")

The same thing applies to 'Yes' and 'yes', of course.

As for the second problem, you're trying to compare a single character with a string. You need to consider your 'Y' as a string too:

if (opt == "y" || opt == "Y" || opt == "yes" || opt == "Yes")
       //  ^^^ Note the double quotes also on single characters