>This doesn't work
What doesn't work? The loop? The checking to see whether it's an integer or a string? What do you want to work? Your question is a bit vague.
> How can I check if the user enters a number instead of a character?
The quickest example I can give in some code is this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include <iostream>
#include <string>
bool getInput(int& input) {
std::cin >> input;
return (!std::cin) ? false : true;
}
int main() {
int myValue;
while(!getInput(myValue)) {
std::cin.clear();
std::cin.ignore(256, '\n');
std::cout << "Value was not of type int!\n";
}
return 0;
}