9.2 Character Processing (<ctype.h>)

The <ctype.h> header file declares several functions for testing characters. For each function, the argument is an int whose value must be EOF or representable as an unsigned char , and the return value is an integer.

Functions

int isalnum(int c);


Returns a nonzero integer if the character passed to it is an alphanumeric ASCII character. Otherwise, isalnum returns 0.

int isalpha(int c);


Returns a nonzero integer if the character passed to it is an alphabetic ASCII character. Otherwise, isalpha returns 0.

int iscntrl(int c);


Returns a nonzero integer if the character passed to it is an ASCII DEL character (177 octal, 0x7F hex) or any nonprinting ASCII character (a code less than 40 octal, 0x20 hex). Otherwise, iscntrl returns 0.

int isdigit(int c);


Returns a nonzero integer if the character passed to it is a decimal digit character (0 to 9). Otherwise, isdigit returns 0.

int isgraph(int c);


Returns a nonzero integer if the character passed to it is a graphic ASCII character (any printing character except a space character). Otherwise, isgraph returns 0.

int islower(int c);


Returns a nonzero integer if the character passed to it is a lowercase alphabetic ASCII character. Otherwise, islower returns 0.

int isprint(int c);


Returns a nonzero integer if the character passed to it is an ASCII printing character, including a space character. Otherwise, isprint returns 0.

int ispunct(int c);


Returns a nonzero integer if the character passed to it is an ASCII punctuation character (any printing character that is nonalphanumeric and greater than 40 octal, 0x20 hex). Otherwise, ispunct returns 0.

int isspace(int c);


Returns a nonzero integer if the character passed to it is white space. Otherwise, isspace returns 0. The standard white space characters are:

int isupper(int c);


Returns a nonzero integer if the character passed to it is an uppercase alphabetic ASCII character. Otherwise, isupper returns 0.

int isxdigit(int c);


Returns a nonzero integer if the character passed to it is a hexadecimal digit (0 to 9, A to F, or a to f). Otherwise, isxdigit returns 0.

int tolower(int c);


Converts an uppercase letter to lowercase. c remains unchanged if it is not an uppercase letter.

int toupper(int c);


Converts a lowercase letter to uppercase. c remains unchanged if it is not a lowercase letter.


Previous Page | Next Page | Table of Contents | Index