I cannot figure out what is the problem

Hello everyone,

I started to learn C++ some hours ago. Long ago I learned Pascal and I remembered one of my first tutorial programs, so I started to code it in C++ too.
The program is about guessing a number.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <iostream>

int main()
{
	int guess, number, error, tries;
	char answer;
		
		tries = 0;
		do
		{

			tries++;
			number = rand();
			std::cout << "I think of a number. Guess it!";
			std::cout << "\nYour Guess: ";
			std::cin >> guess;
			do
			{
				if (guess > number)
				{
					std::cout << "The number is smaller!\n";
					std::cout << "New guess: ";
					std::cin >> guess;
				}
				if (guess < number)
				{
					std::cout << "The number is bigger!\n";
					std::cout << "New guess: ";
					std::cin >> guess;
				}
			}while(guess != number);
			std::cout << "\nCongratulations! You won!\nNumber of tries: " << tries;
			do
			{
				std::cout << "\nDo you want to play again?(y/n) ";
				std::cin >> answer;

				if (answer != "n" || answer != "N" || answer != "y" || answer != "Y")
				{
					std::cout << "Error! Please reply only with the 'y' or 'n' button!\n(Help: y means yes, n means no.)";
					error = 1;
				}
				else
				{
					error = 0;
				}
			}while(error == 1);
		}while(answer == "y" || answer == "Y");

	return 0;
}


Errors I get when I debug at every line where I try to use (answer == "*char*") or (answer != "*char*")
error C2040: 'int' differs in levels of indirection from 'const char [2]'
error C2446: no conversion from 'const char *' to 'int'

I'd be glad if someone could help me!
Thanks in advance
The variable answer is type char, whereas you are comparing it to a "String". You need to compare it to a char 'c' instead. ;)
thanks
Topic archived. No new replies allowed.