C Language: isalnum function
(Test for Alphanumeric)
In the C Programming Language, the isalnum function tests whether c is alphanumeric.
Syntax
The syntax for the isalnum function in the C Language is:
int isalnum(int c);
Parameters or Arguments
- c
- The value to test whether it is alphanumeric.
Note
- c is considered to be alphanumeric if either isalpha(c) is true or isdigit(c) is true.
Returns
The isalnum function returns a nonzero value if c is alphanumeric and returns zero if c is not alphanumeric.
Required Header
In the C Language, the required header for the isalnum function is:
#include <ctype.h>
Applies To
In the C Language, the isalnum function can be used in the following versions:
- ANSI/ISO 9899-1990
isalnum Example
/* Example using isalnum by TechOnTheNet.com */ #include <stdio.h> #include <ctype.h> int main(int argc, const char * argv[]) { /* Define a temporary variable */ unsigned char test; /* Assign a test letter to the variable */ test = 'T'; /* Test to see if this character is alphanumeric */ if (isalnum(test) != 0) printf("%c is alphanumeric\n", test); else printf("%c is not alphanumeric\n", test); /* Assign a non-alphanumeric character to the variable */ test = '!'; /* Test to see if this character is alphanumberic */ if (isalnum(test) != 0) printf("%c is alphanumeric\n", test); else printf("%c is not alphanumeric\n", test); return 0; }
When compiled and run, this application will output:
T is alphanumeric ! is not alphanumeric
Similar Functions
Other C functions that are similar to the isalnum function:
See Also
Other C functions that are noteworthy when dealing with the isalnum function:
Advertisements