Very simplified version of my code:
#include <iostream>
#include <string>
using namespace std;
int main () {
string name;
cout << "Enter first and last name" << endl;
getline(cin, name);
return 0;
}
As you can see I want my user to type in their first and last name which will include white spaces. I would like to check it for numeric characters and if any are entered, throw up an error. An example input could be: “J0hn Sm1th” which would of course display an error.
I know I will have to use isAlpha() and I can get it to work if just numbers or if just letters are entered, but not when they are combined.
1 Answer