C++ 本地化库 - ispunct



描述

它检查字符是否为标点符号字符,其他语言环境可能会将不同的字符选择视为标点符号字符,但在任何情况下,它们都是 isgraph 但不是 isalnum。

声明

以下是 std::ispunct 的声明。

C++98

int ispunct ( int c );

C++11

int ispunct ( int c );

参数

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

返回值

它返回一个非零值。

异常

无异常保证 - 此函数从不抛出异常。

示例

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

#include <stdio.h>
#include <ctype.h>
int main () {
   int i=0;
   int cx=0;
   char str[]="tutorialspoint 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.
locale.htm
广告

© . All rights reserved.