Home C&C++函数库 c++ 语法 程序源码 Linux C库

isspace

函数   <cctype>

int isspace ( int c )

检查字符是否为空白

检查c是否为空白字符

对于“C”语言环境,空白字符是:
' ' (0x20) 空格 (SPC)
'\t' (0x09) 水平制表符 (TAB)
'\n' (0x0a) 换行符(LF)
'\v' (0x0b) 垂直制表符(VT)
'\f' (0x0c) 换页(FF)
'\r' 0x0d 回车符(CR)
其他地区可能会选择不同的字符作为空格,但绝不会是isalnum返回true的字符。
有关不同ctype函数对标准ASCII字符集的每个字符返回的详细图表, 请参阅<cctype>头文件的参考资料。
在c++中,该函数的特定区域的模板版本(isspace )存在于头文件<locale>中。

☲  参数


c

将要被检查、转换为int或EOF的字符。

☉  返回值



如果c确实是一个空白字符,返回一个不等于零的值(如,true)。否则返回零(即false)。

☣  示例



/* isspace example */
#include <stdio.h>
#include <ctype.h>
int main ()
{
  char c;
  int i=0;
  char str[]="Example sentence to test isspace\n";
  while (str[i])
  {
    c=str[i];
    if (isspace(c)) c='\n';
    putchar (c);
    i++;
  }
  return 0;
}

这段代码一个字符一个字符地打印出C字符串,并用换行符替换任何空白字符。 输出:
Example
sentence
to
test
isspace



🍄  另请参阅



ispunct 检查字符是否是标点符号(function )
isgraph 检查字符是否是图形(function )
isalnum 检查字符是否是字母数字(function )
isspace (locale) 使用区域设置检查字符是否为空白(function template)

联系我们 免责声明 关于CandCplus 网站地图