ctype中的各种函数 Character handling functions
来源:互联网 发布:system01.dbf数据大 编辑:程序博客网 时间:2024/06/05 05:07
<cctype>
(ctype.h)
isalnum
是否是字母或者数字
Check if character is alphanumeric
Checks whether c is either a decimal digit or an uppercase or lowercase letter.
/* isalnum example */#include <stdio.h>#include <ctype.h>int main (){ int i; char str[]="c3po..."; i=0; while (isalnum(str[i])) i++; printf ("The first %d characters are alphanumeric.\n",i); return 0;}Output:The first 4 characters are alphanumeric.
isalpha
是否是字母
/* isalpha example */ #include <stdio.h> #include <ctype.h> int main () { int i=0; char str[]="C++"; while (str[i]) { if (isalpha(str[i])) printf ("character %c is alphabetic\n",str[i]); else printf ("character %c is not alphabetic\n",str[i]); i++; } return 0; } Output: character C is alphabetic character + is not alphabetic character + is not alphabeti
isblank
是否是空格
Check if character is blank
Checks whether c is a blank character.
A blank character is a space character used to separate words within a line of text.
The standard “C” locale considers blank characters the tab character (‘\t’) and the space character (’ ‘).
Other locales may consider blank a different selection of characters, but they must all also be space characters by isspace.
For a detailed chart on what the different ctype functions return for each character of the standard ASCII character set, see the reference for the header.
In C++, a locale-specific template version of this function (isblank) exists in header .
Compatibility note: Standardized in C99 (C++11).
/* isblank example */#include <stdio.h>#include <ctype.h>int main (){ char c; int i=0; char str[]="Example sentence to test isblank\n"; while (str[i]) { c=str[i]; if (isblank(c)) c='\n'; putchar (c); i++; } return 0;}This code prints out the C string character by character, replacing any blank character by a newline character. Output:Examplesentencetotestisblank
iscntrl
是否是控制符(0-31,127)
Check if character is a control character
Checks whether c is a control character.
A control character is a character that does not occupy a printing position on a display (this is the opposite of a printable character, checked with isprint).
For the standard ASCII character set (used by the “C” locale), control characters are those between ASCII codes 0x00 (NUL) and 0x1f (US), plus 0x7f (DEL).
For a detailed chart on what the different ctype functions return for each character of the standard ANSII character set, see the reference for the header.
In C++, a locale-specific template version of this function (iscntrl) exists in header .
isdigit
是否是数字
/* isdigit example */
#include
isgraph
是否是图形化字符(大于31除开127,不包含空格)
Check if character has graphical representation
Checks whether c is a character with graphical representation.
The characters with graphical representation are all those characters than can be printed (as determined by isprint) except the space character (' ').For a detailed chart on what the different ctype functions return for each character of the standard ASCII character set, see the reference for the <cctype> header.In C++, a locale-specific template version of this function (isgraph) exists in header <locale>.
islower
Check if character is lowercase letter
isprint
是否可打印(大于31除开127,包括空格)
Check if character is printable
Checks whether c is a printable character.
A printable character is a character that occupies a printing position on a display (this is the opposite of a control character, checked with iscntrl).
For the standard ASCII character set (used by the “C” locale), printing characters are all with an ASCII code greater than 0x1f (US), except 0x7f (DEL).
isgraph returns true for the same cases as isprint except for the space character (’ ‘), which returns true when checked with isprint but false when checked with isgraph.
For a detailed chart on what the different ctype functions return for each character of the standard ANSII character set, see the reference for the header.
In C++, a locale-specific template version of this function (isprint) exists in header .
ispunct
是否是标点符号(isgraph中除开字母和数字)
Check if character is a punctuation character
Checks whether c is a punctuation character.
The standard “C” locale considers punctuation characters all graphic characters (as in isgraph) that are not alphanumeric (as in isalnum).
Other locales may consider a different selection of characters as punctuation characters, but in any case they are isgraph but not isalnum.
For a detailed chart on what the different ctype functions return for each character of the standard ANSII character set, see the reference for the header.
In C++, a locale-specific template version of this function (ispunct) exists in header .
isspace
是否是空格
Check if character is a white-space
Checks whether c is a white-space character.
For the “C” locale, white-space characters are any of:
’ ’ (0x20) space (SPC)
‘\t’ (0x09) horizontal tab (TAB)
‘\n’ (0x0a) newline (LF)
‘\v’ (0x0b) vertical tab (VT)
‘\f’ (0x0c) feed (FF)
‘\r’ (0x0d) carriage return (CR)
Other locales may consider a different selection of characters as white-spaces, but never a character that returns true for isalnum.
For a detailed chart on what the different ctype functions return for each character of the standard ASCII character set, see the reference for the header.
In C++, a locale-specific template version of this function (isspace) exists in header .
isupper
Check if character is uppercase letter
isxdigit
是否是16进制
Check if character is hexadecimal digit
tolower
Convert uppercase letter to lowercase
toupper
Convert lowercase letter to uppercase
附:
- ctype中的各种函数 Character handling functions
- ctype库中的函数isalnum
- Ctype.h中的常用函数
- PHP中处理函数的函数(Function Handling Functions)
- c中的ctype.h字符函数
- ctype.h中的函数与功能
- Basic String Handling Functions
- PHP Function handling functions
- CType 函数
- Samba Character Handling System
- Character Functions & Number Functions & Date Functions
- Oracle Character Functions
- Windows Shell Registry Handling Functions
- Exception Handling Functions for Debugging
- RTAI API-----Message handling functions
- 我们平常很少用到的PHP中处理函数的函数(Function Handling Functions)
- PHP - Manual手册 - XXXIII. Error Handling and Logging Functions错误处理和日志函数 - 概述
- ctype.h中函数
- Unity Shader学习笔记:坐标空间
- 阿里ECS无法telnet到smtp 25号端口的解决方案
- wps个人免费版支持宏操作
- 快速排序的递归与非递归实现
- jquery li循环轮播切换
- ctype中的各种函数 Character handling functions
- jquery 父页面控制子页面IFRAME
- 摩尔斯电报码 解码算法 (Python 语言描述)
- jdom操作xml文件
- Intellij IDEA 2017新特性之Spring Boot相关
- 基于VPX总线架构下的Virtex-7与C6678信号处理的VPX功能板简介
- 分布科技携手复星集团 区块链“赋能”产业经济
- 织梦dedecms标签dede:productimagelist每张图片不同样式输出
- mongodb安装