isalnum() - Character Function

How is "isalnum()" used in C++?


isalnum() is used to check whether the given argument is alphanumeric character (integer or uppercase/lowercase alphabets). This function returns zero when the argument does not have any of them.


int isalnum ( int c );

Example :

#include <iostream.h>
#include <ctype.h>
int main()
char a;
cout << "Enter a alphanumeric character::\n" << endl;
cin >> a;
cout << "Alpha-numeric character";
cout << "Not a Alpha-numeric";
return 0;

Result :

Enter a alphanumeric character::
Alpha-numeric character

In the above example, this function is used to check if the entered number is alphanumeric. It checks if the ASCII value passed in has a character equivalent to a number of letter.

C++ Tutorial

Ask Questions

Ask Question