User manual

MPLAB
®
XC8 C Compiler User’s Guide
DS52053B-page 338 2012 Microchip Technology Inc.
Note
The example will require the user to provide the time() routine as one cannot be
supplied with the compiler. See time() for more detail.
ISALNUM, ISALPHA, ISDIGIT, ISLOWER, ET. AL.
Synopsis
#include <ctype.h>
int isalnum (char c)
int isalpha (char c)
int isascii (char c)
int iscntrl (char c)
int isdigit (char c)
int islower (char c)
int isprint (char c)
int isgraph (char c)
int ispunct (char c)
int isspace (char c)
int isupper (char c)
int isxdigit(char c)
Description
These macros, defined in ctype.h, test the supplied character for membership in one
of several overlapping 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
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);
}