Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
isalnum
Function: Determine if a character is alphanumeric.
Include: ctype.h
Prototype: unsigned char isalnum( unsigned char ch );
Arguments: ch
Character to be checked.
Remarks: A character is considered to be alphanumeric if it is in the range of ‘A’ to
‘Z’, ‘a’ to ‘z’ or ‘0’ to ‘9’.
Return Value: Non-zero if the character is alphanumeric
Zero otherwise
File Name: isalnum.c
Description
These macros, defined in ctype.h, test the supplied character for membership in one of several over-
lapping groups of characters. Note that all except isascii() are defined for c, if isascii(c) is true or if
c = EOF.
isalnum(c) c is in 0-9 or a-z or A-Z
isalpha(c) c is in A-Z or a-z
isascii(c) c is a 7 bit ascii character
iscntrl(c) c is a control character
isdigit(c) c is a decimal digit
islower(c) c is in a-z
isprint(c) c is a printing char
isgraph(c) c is a non-space printable character
ispunct(c) c is not alphanumeric
isspace(c) c is a space, tab or newline
isupper(c) c is in A-Z
isxdigit(c) c is in 0-9 or a-f or A-F
255
Example
#include <ctype.h>
#include <stdio.h>
void
main (void)
{
char buf[80];
int i;
gets(buf);
i = 0;
while(isalnum(buf[i]))
i++;
buf[i] = 0;
printf("’%s’ is the word\n", buf);
}
See Also
toupper(), tolower(), toascii()
A stream is for IO. A string is for well... strings.Stream and string are one and the same.....
C18 makes extensive use of union in its processor header files.I prefer to use unions rather than bitmasking by code for example, something I was unsure if C18 supported, but it does, in fact the MCHIP C compilers are quite good at complying with ANSI C.