Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

c++
communitycreator

What is isalnum() in C++?

Salman Yousaf

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

In C++Object-Oriented Programming Language, 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.

char in C++ is a special type of datatype that deals with alphabet values. From a memory perspective, C++ char is of 1 byte.

Return value

  • Nonzero: if the argument values are in the range (a-z,A-Z,0-9), then isalnum returns a non-zero value, i.e., TRUE.

  • 0: if the argument is not between the defined range(a-z,A-Z,0-9), then isalnum returns 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;
} else
cout << "FALSE at " << num;
return 0;
}

RELATED TAGS

c++
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring