一、头文件 <ctype.h>
1、字符分类函数
函数名 | 功能 |
iscntrl | 是控制字符,返回非0值;否则,返回0 |
isspace | 是空白字符(空格、‘\f’、‘\n’、‘\r’等),返回非0值;否则,返回0 |
isdigit | 是十进制数字(0~9),返回非0值;否则,返回0 |
isxdigit | 是十六进制数(包括十进制数字、小写字母a~f、大写A~F),返回非0值;否则,返回0 |
islower | 是小写字母,返回非0值;否则,返回0 |
isupper | 是大写字母,返回非0值;否则,返回0 |
isalpha | 是字母a~z或A~Z,返回非0值;否则,返回0 |
isalnum | 是字母或数字,返回非0值;否则,返回0 |
ispunct | 是标点符号及图形字符(不属于数字或字母),返回非0值;否则,返回0 |
isgraph | 是任何图形字符,返回非0值;否则,返回0 |
isprint | 是任何可打印字符(包括图形字符和空白字符),返回非0值;否则,返回0 |
2、字符转换函数
函数名 | 功能 |
tolower | 将参数中的大写字母转换为小写字母 |
toupper | 将参数中的小写字母转换为大写字母 |
二、头文件 <string.h>
函数名 | 功能 |
strlen | 统计字符串中'\0'之前字符的个数 |
函数名 | 功能 | 参数 | 函数名 | 功能 | 参数 |
strcpy | 将源字符串拷贝到目标空间中 | char * strcpy ( char * destination, const char * source ); | strncpy | 从源字符串中拷贝num个字符到目标空间中 | char * strncpy ( char * destination, const char * source, size_t num ); |
strcat | 将源字符串连接到目标字符串的后面 | char * strcat ( char * destination, const char * source ); | strncat | 从源字符串中连接num个字符到目标空间中 | char * strncat ( char * destination, const char * source, size_t num ); |
strcmp | 两个字符串进行比较 | int strcmp ( const char * str1, const char * str2 ); | strncmp | 比较两个字符串的前num个字符 | int strncmp ( const char * str1, const char * str2, size_t num ); |
函数名 | 功能 | 参数 |
strstr | 在一个字符串中查找另一个字符串,并返回在另一个字符串中第一次出现的位置 | char * strstr ( char * str1, const char * str2 ); |
strtok | 对含有分隔符的字符串进行切分 | char * strtok ( char * str, const char * delimiters ); |
strerror | 返回参数部分错误码对应的错误信息的字符串地址 | char * strerror ( int errnum ); |