Why in the world will it not let me cin "a" if cin is not an int? It displays the cout statement in the if statement but any cin statement will not work in there?? I made a random number guessing game a long time ago and if your guess was not equal to the random number I had the user enter a new number. And I put the cin statement in the if statement and it worked fine...Why won't it work now??
If I put a cout statement after the second cin it will display it. So it's running the whole thing.
I am way past this in my c++ knowledge and I am aware of exception handling and everything but I'm just wondering why this specific code won't work?Code:int a; cout << "Enter number\n"; cin >> a; if(!cin.good()) { cout << "number only\n"; cin >> a; }