Catching Input Exceptions

Hello! I am trying to write a program to receive from the user an acceptable input. So if the user inputs, say, a string, then I put her in a loop and until she inputs an integer. She will never be able to escape the loop. MUHAHAHA! Anyhow, any suggestions to accomplish this?

1
2
3
4
5
6
7
        int choice = 0; 
	cin >> choice;
	while (cin.fail() == 1) {
		cin.ignore(); 
		cin >> choice; 
		cin.fail();
	}
Topic archived. No new replies allowed.