# <ctype.h>
<ctype.h>
# ``
* * *
**`isalnum· isalpha· iscntrl· isdigit· isgraph· islower· isprint· ispunct· isspace· isupper· isxdigit· tolower· toupper`**
* * *
Include the standard header **``**
to declare several functions that are useful
for classifying and mapping codes from the
target character set. Every function that has a parameter of type
*int* can accept the value of the macro
[`EOF`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_stdio.html#EOF) or any value
representable as type *unsigned char.* Thus, the argument can
be the value returned by any of the functions
[`fgetc`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_stdio.html#fgetc),
[`fputc`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_stdio.html#fputc),
[`getc`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_stdio.html#getc),
[`getchar`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_stdio.html#getchar),
[`putc`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_stdio.html#putc),
[`putchar`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_stdio.html#putchar),
[`tolower`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_ctype.html#tolower),
[`toupper`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_ctype.html#toupper), and
[`ungetc`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_stdio.html#ungetc).
You must not call these functions
with other argument values.
Other library functions use these functions. The function
[`scanf`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_stdio.html#scanf),
for example, uses the function
[`isspace`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_ctype.html#isspace)
to determine valid white space within an input field.
The
**character classification**
functions are strongly interrelated.
Many are defined in terms of other functions. For characters in the
[basic C character set](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_charset.html#basic%20C%20character%20set), here are
the dependencies between these functions:

The diagram indicates with `+` those functions that can
define additional characters in locales other than the
[`"C"`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_locale.html#C%20locale) locale.
The diagram tells you that the function
[`isprint`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_ctype.html#isprint)
returns nonzero for `space` or for
any character for which the function
[`isgraph`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_ctype.html#isgraph) returns nonzero.
The function
[`isgraph`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_ctype.html#isgraph), in turn,
returns nonzero for any character for which either the function
[`isalnum`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_ctype.html#isalnum) or the function
[`ispunct`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_ctype.html#ispunct)
returns nonzero. The function
[`isdigit`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_ctype.html#isdigit),
on the other hand, returns nonzero only for the digits
`0-9`.
An implementation can define additional characters that return
nonzero for some of these functions. Any character set can contain
additional characters that return nonzero for:
- [`iscntrl`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_ctype.html#iscntrl)
(provided the characters cause
[`isprint`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_ctype.html#isprint) to return zero)
- [`ispunct`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_ctype.html#ispunct)
(provided the characters cause
[`isalnum`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_ctype.html#isalnum) to return zero)
The diagram indicates with `++` those functions that can
define additional characters in any character set.
Moreover, locales other than the
[`"C"`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_locale.html#C%20locale) locale
can define additional characters that return nonzero for:
- [`isalpha`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_ctype.html#isalpha),
[`isupper`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_ctype.html#isupper), and
[`islower`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_ctype.html#islower)
(provided the characters cause
[`iscntrl`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_ctype.html#iscntrl),
[`isdigit`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_ctype.html#isdigit),
[`ispunct`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_ctype.html#ispunct), and
[`isspace`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_ctype.html#isspace) to return zero)
- [`isspace`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_ctype.html#isspace)
(provided the characters cause
[`isprint`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_ctype.html#isprint) to return zero)
Note that an implementation can define locales other than the
[`"C"`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_locale.html#C%20locale) locale
in which a character can cause
[`isalpha`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_ctype.html#isalpha) (and hence
[`isalnum`)](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_ctype.html#isalnum)
to return nonzero, yet still cause
[`isupper`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_ctype.html#isupper) and
[`islower`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_ctype.html#islower) to return zero.
int isalnum(int c);
int isalpha(int c);
int iscntrl(int c);
int isdigit(int c);
int isgraph(int c);
int islower(int c);
int isprint(int c);
int ispunct(int c);
int isspace(int c);
int isupper(int c);
int isxdigit(int c);
int tolower(int c);
int toupper(int c);Copy to clipboard
## `isalnum`
int isalnum(int c);Copy to clipboard
The function returns nonzero if `c` is any of:
a b c d e f g h i j k l m n o p q r s t u v w x y z
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
0 1 2 3 4 5 6 7 8 9Copy to clipboard
or any other locale-specific alphabetic character.
## `isalpha`
int isalpha(int c);Copy to clipboard
The function returns nonzero if `c` is any of:
a b c d e f g h i j k l m n o p q r s t u v w x y z
A B C D E F G H I J K L M N O P Q R S T U V W X Y ZCopy to clipboard
or any other locale-specific alphabetic character.
## `iscntrl`
int iscntrl(int c);Copy to clipboard
The function returns nonzero if `c` is any of:
BEL BS CR FF HT NL VTCopy to clipboard
or any other implementation-defined control character.
## `isdigit`
int isdigit(int c);Copy to clipboard
The function returns nonzero if `c` is any of:
0 1 2 3 4 5 6 7 8 9Copy to clipboard
## `isgraph`
int isgraph(int c);Copy to clipboard
The function returns nonzero if `c`
is any character for which either
[`isalnum`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_ctype.html#isalnum) or
[`ispunct`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_ctype.html#ispunct) returns nonzero.
## `islower`
int islower(int c);Copy to clipboard
The function returns nonzero if `c` is any of:
a b c d e f g h i j k l m n o p q r s t u v w x y zCopy to clipboard
or any other locale-specific lowercase character.
## `isprint`
int isprint(int c);Copy to clipboard
The function returns nonzero if `c` is
`space` or a character for which
[`isgraph`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_ctype.html#isgraph) returns nonzero.
## `ispunct`
int ispunct(int c);Copy to clipboard
The function returns nonzero if `c` is any of:
! " # % & ' ( ) ; <
= > ? [ \ ] * + , -
. / : ^ _ { | } ~Copy to clipboard
or any other implementation-defined punctuation character.
## `isspace`
int isspace(int c);Copy to clipboard
The function returns nonzero if `c` is any of:
CR FF HT NL VT spaceCopy to clipboard
or any other locale-specific space character.
## `isupper`
int isupper(int c);Copy to clipboard
The function returns nonzero if `c` is any of:
A B C D E F G H I J K L M N O P Q R S T U V W X Y ZCopy to clipboard
or any other locale-specific uppercase character.
## `isxdigit`
int isxdigit(int c);Copy to clipboard
The function returns nonzero if `c` is any of:
0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E FCopy to clipboard
## `tolower`
int tolower(int c);Copy to clipboard
The function returns the corresponding lowercase letter if one
exists and if
`isupper(c)`;
otherwise, it returns `c`.
## `toupper`
int toupper(int c);Copy to clipboard
The function returns the corresponding uppercase letter if one
exists and if
`islower(c)`;
otherwise, it returns `c`.
* * *
See also the
**[Table of Contents](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_index.html#Table%20of%20Contents)** and the
**[Index](https://docs.qualcomm.com/doc/80-N3040-23/topic/_cpp_index.html)**.
*[Copyright](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_crit_pjp.html) © 1992-2006by P.J. Plauger and Jim Brodie. All rights reserved.*
Last Published: Oct 06, 2026
Previous Topic
Next Topic