English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
If the parameter (character) passed to this function is an alphabetic or numeric character, the isalnum() function will return a non-zero integer.
int isalnum(int argument);
When a character is passed as an argument, it will pass the corresponding ASCII value (integer) of the character, rather than passing the character itself.
This function inIn the ctype.h header fileDefinition.
#include <stdio.h> #include <ctype.h> int main() { char c; int result; c = '5'; result = isalnum(c); printf("Pass %c, the return value is %d\n", c, result); c = 'Q'; result = isalnum(c); printf("Pass %c, the return value is %d\n", c, result); c = 'l'; result = isalnum(c); printf("Pass %c, the return value is %d\n", c, result); c = '+'; result = isalnum(c); printf("Pass %c, the return value is %d\n", c, result); return 0; }
Output Result
Pass 5 When, the return value is 1 Pass Q, the return value is 1 Pass l, the return value is 1 Pass + When, the return value is 0
#include <stdio.h> #include <ctype.h> int main() { char c; printf("Enter a character: "); scanf("%c", &c); if (isalnum(c) == 0) printf("%c is not an alphanumeric character.", c); else printf("%c is a alphanumeric character.", c); return 0; }
Output Result
Enter a character: 0 0 is a alphanumeric character.