I want it to do the following:
Ask for a number between 1 and 5, if user inputs anything lower, higher, or something that isn't a number, it should give an error message and then ask for a input again.
This code will spam the error message forever,
what have I done wrong?
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
int main()
{
//vars
int user_number;
cout
<<"Please pick a number between 1 and 5"
<<endl
<<endl;
cin >> user_number;
while(user_number<1 || user_number >5 || isdigit(user_number)==false)
{
cout <<"I said a number between 1 and 5! =(" <<endl;
cin >> user_number;
}
cout <<"You choose "<<user_number;
system("pause");
return 1;
}