Solution:"
You have two ways to solve this. The preferred method is to use:
string answer;
(instead of char
). The other possible method to solve it is:
if (answer == 'y') ...
note single quotes instead of double, illustrating a char
constant
A string literal is delimited by quotation marks and is of type char* not char.
Example: "hello"
Hence at the time you compare a char to a char* you will obtain that similar compiling error.
char c = 'c';
char *p = "hello";
if(c==p)//compiling error
{
}
To solve exercise a char literal which is delimited by single quotes.
Example: 'c'
You should remember to employ single quotes for char constants. So exercise
if (answer == 'y') return true;
Rather than
if (answer == "y") return true;