Home » C programs » ctype.h header file functions

isalnum() function of ctype.h in C

In this article, we are going to learn about the use isalnum() function of ctype.h header file in C language and use it to check various conditions.
Submitted by Manu Jemini, on April 04, 2018

We can use a simple function to check a character if it’s alphanumeric or not. The Function is called isalnum( param a), which accepts a single parameter which defines a character.

There can be numerous cases when we can use this function like checking for the characters in the password or username. A lot of websites have checks on emails, usernames, passwords etc.

The isalnum() function returns true if the character is alpha numeric and false if character is not alpha numeric. This can be useful if you want to check for sql injections.

This function is from the ctype.h file which needs to be included in the program.

ctype.h - isalnum() function Example in C

#include <stdio.h>
#include <ctype.h>
int main()
	// Defining the type of variables and initializing them
	char a='A';
	char b='@';
	// condition to prove that the value a is character
	If ( isalnum(a) == 1 )
		printf("%c is a character \n\n", a);
	// condition to prove that the value b is not a character
	If ( isalnum(b)== 0 )
		printf("%c is not a character \n", b);
	return 0;


ctype.h - isalnum()  in c language

Was this page helpful? Please share with your friends...

Are you a blogger? Join our Blogging forum.

Comments and Discussions

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com (2015-2018), Some rights reserved.

close Like other websites, this site uses cookies to deliver relevant ads based on your interest, by using our website, you acknowledge that you have read our privacy policy.