What is isalnum() in C++?
In isalnum() is used to check if the input value is either an alphabet or a number.
Syntax
int isalnum(char ch);
Parameters
ch: a character of type char.
charin C++ is a special type of datatype that deals with alphabet values. From a memory perspective, C++charis of 1 byte.
Return value
-
Nonzero: if the argument values are in the range (a-z,A-Z,0-9), thenisalnumreturns a non-zero value, i.e.,TRUE. -
0: if the argument is not between the defined range(a-z,A-Z,0-9), thenisalnumreturns 0, i.e.,FALSE.
Code
In the example below, we pass the English alphabet a as an argument, which returns a non-zero value.
#include <iostream>using namespace std;int main() {int num = isalnum('a');if (num) {cout << "TRUE at " << num;} elsecout << "FALSE at " << num;return 0;}