English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

C Language Basic Tutorial

C Language Flow Control

C Language Functions

C Language Arrays

C Language Pointers

C Language Strings

C Language Structures

C Language Files

C Others

C Language Reference Manual

C Standard Library <ctype.h>

The C language <ctype.h> header file declares a set of functions to classify (and convert) individual characters. For example, isupper() checks whether a character is uppercase.

Introduction

C Standard Library ctype.h The header file provides some functions that can be used to test and map characters.

These functions accept int As a parameter, its value must be EOF or represented as an unsigned character.

If the parameter c meets the described conditions, these functions return non-zero (true). If the parameter c does not meet the described conditions, these functions return zero.

Library functions

The following lists the functions defined in the header file ctype.h:

NumberFunction & Description
1int isalnum(int c)
This function checks if the character passed is a letter and a number.
2int isalpha(int c)
This function checks if the character passed is a letter.
3int iscntrl(int c)
This function checks if the character passed is a control character.
4int isdigit(int c)
This function checks if the character passed is a decimal digit.
5int isgraph(int c)
This function checks if the character passed has a graphic representation.
6int islower(int c)
This function checks if the character passed is a lowercase letter.
7int isprint(int c)
This function checks if the character passed is printable.
8int ispunct(int c)
This function checks if the character passed is a punctuation symbol character.
9int isspace(int c)
This function checks if the character passed is a whitespace character.
10int isupper(int c)
This function checks if the character passed is an uppercase letter.
11int isxdigit(int c)
This function checks if the character passed is a hexadecimal digit.

The standard library also includes two conversion functions that accept and return an "int"

NumberFunction & Description
1int tolower(int c)
This function converts an uppercase letter to a lowercase letter.
2int toupper(int c)
This function converts a lowercase letter to an uppercase letter.

Character class

NumberCharacter class & Description
1Digits
Complete set of digits { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }
2Hexadecimal digits
Set { 0 1 2 3 4 5 6 7 8 9 Set { A B C D E F a b c d e f }
3Lowercase letters
Set { 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 }
4Uppercase letters
Set {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 }
5Letters
The set of lowercase letters and uppercase letters
6Alphanumeric characters
The set of digits, lowercase letters, and uppercase letters
7Punctuation symbol characters
Set ! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~
8Graphic characters
The set of alphanumeric characters and punctuation symbols.
9Space character
The set of tab, newline, vertical tab, form feed, carriage return, and space characters.
10Printable characters
The set of alphanumeric characters, punctuation characters, and space characters.
11Control characters
In ASCII encoding, the octal codes of these characters range from 000 to 037as well as 177(DEL).
12Whitespace characters
Including space characters and tab characters.
13Letter characters
The set of lowercase and uppercase letters.