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.