Character Class Tests: <b>ctype.h</b>




Document: The C Standard Library

next String Functions: string.h
up The C Standard Library
gif void assert(int status)

Character Class Tests: ctype.h

ctype.h provides prototypes for a selection of functions which test a char value for membership of a given class. In each case the function takes a single argument, which is technically of type int, but which represents a char value or, possibly, EOF; this is for compatibility with fgetc() as discussed earlier. The return value is always of type int, being zero (false) if the value is not a member of the relevant class, or non-zero (true) if it is.

Some examples are as follows:

int isalpha(int c) : Letter (i.e. "alphabetic")?
int isdigit(int c) : Digit?
int isalnum(int c) : Letter or digit ("alphanumeric")?
int islower(int c) : Lower case letter?
int isupper(int c) : Upper case letter?
int isspace(int c) : "Whitespace" (i.e. space, newline, tab, etc.)?
int isprint(int c) : Printable or displayable (including space)?

ctype.h also provides two functions which convert the case of letters:

int tolower(int c)
int toupper(int c)




Document: The C Standard Library

next String Functions: string.h
up The C Standard Library
gif void assert(int status)



McMullin@eeng.dcu.ie
Fri Mar 29 14:35:38 GMT 1996