c++ know if char is alphanumeric code example
Example 1: check if character in string is alphabet c++
int main() {
char val1 = 's';
char val2 = '8';
if(isalpha(val1))
printf("The character is an alphabet\n");
else
printf("The character is not an alphabet\n");
if(isalpha(val2))
printf("The character is an alphabet\n");
else
printf("The character is not an alphabet");
return 0;
}
Example 2: c++ isalphanum
string test = "Ab4 :";
std::isalnum(test[0]); //true
std::isalnum(test[1]); //true
std::isalnum(test[2]); //true
std::isalnum(test[3]); //false
std::isalnum(test[4]); //false