I am trying to write something which takes user input (int) and doesn't cause an error if user inputs something other than an out of range int or an alpha. What I have actually works fine on my computer with XP but it causes errors on all 3 of my win98/ME computers. I have traced it down to the problem being with the use of char and casting but no idea exactly what the problem is or how to fix it. Below is an edited piece of my code. Also, maybe even a dumber question, but why can't I declare my variables outside main without error?
#include <iostream>
#include <stdlib.h>
using namespace std;
int main()
{
char *numb;
int number;
cout<<" Enter a number 1-10 ";
cin>>numb;
number=atoi(numb);
while((number<1)||(number>10)){
cout<<"\n\n You must enter a number between 1 and 10 ";
cin>>numb;
number=atoi(numb);
}
cout<<"\n Correct selection!";
cin.ignore();
cin.get();
return 0;
}