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

ispunct

函数   <cctype>

int ispunct ( int c )

检查字符是否是标点符号

检查c是否为标点符号。

标准的“C”语言环境认为标点字符是图形字符(如isgraph), 而不是字母数字字符(如isalnum)。
其他地区可能会考虑使用不同的字符作为标点符号,但在任何情况下,它们都是isgraph 而不是isalnum
有关不同ctype函数对标准ASCII字符集的每个字符返回的详细图表,请参阅<cctype>头文件的参考资料。
在c++中,该函数的特定区域的模板版本(ispunct)存在于头文件<locale>中。

☲  参数


c

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

☉  返回值



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

☣  示例



/* ispunct example */
#include <stdio.h>
#include <ctype.h>
int main ()
{
  int i=0;
  int cx=0;
  char str[]="Hello, welcome!";
  while (str[i])
  {
    if (ispunct(str[i])) cx++;
    i++;
  }
  printf ("Sentence contains %d punctuation characters.\n", cx);
  return 0;
}

输出:
Sentence contains 2 punctuation characters.


🍄  另请参阅



iscntrl 检查字符是否是控制字符(function )
isgraph 检查字符是否是图形(function )

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