Hey,
My codes asks for a number, if the user inputs something else it gives an error message and asked for a number again.
If the user inputs a number, it should cout whatever number the user chose.
But it doesn't work as intended...
I get the error message the ammount of letters i type in, for example
a will give me the error message once
aaa will give me the error message 3 times
Also, if I type in 77 it says that I chose 7........
Here's the code:
#include <iostream>
#include <climits>
#include <cstdio>
#include <cstdlib>
int main()
{
using namespace std;
/* Variables */
char user_input_number;
/* End of Variables */
cout
<<"############################################################################################"
<<"############ Welcome to the house of horrors! ############"
<<"##########################################################################################"
<<endl
<<endl
<<"Please pick a number! ";
cin>>user_input_number;
while(isdigit(user_input_number)==false)
{
cout <<endl
<<"An integer you bozo -_^"
<<endl
<<"Try again: "; cin>>user_input_number;
}
cout
<<"You chose: "<<user_input_number;
cout <<endl<<endl;
system("pause");
return 1;
}