目录

ispunct

描述 (Description)

它检查字符是否是标点字符,其他语言环境可能会将不同的字符选择视为标点字符,但无论如何它们都是isgraph而不是isalnum。

声明 (Declaration)

以下是std :: ispunct的声明。

C++98

int ispunct ( int c );

C++11

int ispunct ( int c );

参数 (Parameters)

c - 要检查的字符,转换为int或EOF。

返回值 (Return Value)

它返回一个不等于零的值。

异常 (Exceptions)

No-throw guarantee - 此函数永远不会抛出异常。

例子 (Example)

在下面的示例中为std :: ispunct。

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

样本输出应该是这样的 -

Sentence contains 1 punctuation characters.
↑回到顶部↑
WIKI教程 @2018