Cant Type At Certain place when i run the project

Hi I am new to C++ and programming in general, Ok so when I run my project and come to the question would you like a quiz? I can not answer it I don't know why but I can write/answer for Hello, How are you today? so I am really stuck here is the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 #include <iostream>
#include <string>
using namespace std;

int main()
{
	string input;

		int i;


	std::cout << "Hello, how are you today?\n";
	cin >> i;

	std::cout << "would you like a quiz?\n";
	cin >> i;

	system("pause");
	return 0;
}

Line 12: Are you really expecting someone to answer with a number?
Line 13: You're doing a cin to an int. If the user doesn't type a number, the cin (line 12) will fail and the data the user typed will still be in the input buffer.

Line 15-16: ditto.

Changes lines 13 and 16 to cin>> input;


Last edited on
Oh yes thank you so much.
Topic archived. No new replies allowed.