0 Members and 1 Guest are viewing this topic.
jonssonj wrote:Hello!I wonder how I can check that a input made by a user, really is an integer and not anything else.int main(void){ int test; cout << "Enter integer: "; cin >> test; // Now I want to check that the user really entered an // integer and not anything else.
if(cin.fail()) { // a number wasn't entered } else { if(!cin.eof()) { // there is more non-numeric input } }}