Programming in C

(Barry) #1
I/O Functions 473

Character Functions


The following functions deal with single characters.To use them, you must include the
file <ctype.h>in your program:
#include <ctype.h>
Each of the functions that follow takes an int(c)as an argument and returns a TRUE
value (nonzero), if the test is satisfied, and a FALSE (zero) value otherwise.
Name Test
isalnum Is can alphanumeric character?
isalpha Is can alphabetic character?
isblank Is ca blank character (space or horizontal tab)?
iscntrl Is ca control character?
isdigit Is ca digit character?
isgraph Is ca graphics character (any printable character except a space)?
islower Is ca lowercase letter?
isprint Is ca printable character (including a space)?
ispunct Is ca punctuation character (any character except a space or
alphanumeric)?
isspace Is ca whitespace character (space, newline, carriage return, hori-
zontal or vertical tab, or formfeed)?
isupper Is can uppercase letter?
isxdigit Is ca hexadecimal digit character?
The following two functions are provided for performing character translation:
int tolower(c)
Returns the lowercase equivalent of c. If cis not an uppercase letter,citself is
returned.
int toupper(c)
Returns the uppercase equivalent of c. If cis not a lowercase letter,citself is
returned.

I/O Functions


The following describes some of the more commonly used I/O functions from the C
library.You should include the header file <stdio.h>at the front of any program that
uses one of these functions, using the following statement:
#include <stdio.h>

21 0672326663 AppB 6/10/04 2:03 PM Page 473

Free download pdf