Hi, I am doing my first c++ app and it's an assignment that I am doing at university (college if you like) and I have an input validated so that a person can't enter a number <1 or > 9 but if they enter a letter it stuffs up the program...
I was wondering if there was a way for me to check if they entered a letter...I will post the code:
cout << "Player " << player << " Please enter where you would like you place your X or O\n";
cin >> gridNumber;
while (gridNumber < 1 || gridNumber > 9)
{
cout << "\n";
cout << "You have entered an invalid number\n";
cout << "Please enter a valid number\n";
cin >> gridNumber;
}
hope someone can help me soonish
thanks heaps in advance guys
I was wondering if there was a way for me to check if they entered a letter...I will post the code:
cout << "Player " << player << " Please enter where you would like you place your X or O\n";
cin >> gridNumber;
while (gridNumber < 1 || gridNumber > 9)
{
cout << "\n";
cout << "You have entered an invalid number\n";
cout << "Please enter a valid number\n";
cin >> gridNumber;
}
hope someone can help me soonish
thanks heaps in advance guys