C/C++ 中的 iswpunct() 函式


函式 iswpunct() 用於檢查傳遞的寬字元是否是標點符號。如果不是標點符號則返回零,否則返回非零值。它在 “cwctype” 標頭檔案宣告中。

以下是 iswpunct() 的語法

int iswpunct(wint_t character);

以下是 iswpunct() 的示例

示例

#include<cwctype>
#include<stdio.h>
using namespace std;
int main() {
   wint_t a = '!';
   wint_t b = 'a';
   if(iswpunct(a))
   printf("The character is a punctuation.");
   else
   printf("\nThe character is not a punctuation.");
   if(iswpunct(b))
   printf("\nThe character is a punctuation.");
   else
   printf("\nThe character is not a punctuation.");
   return 0;
}

輸出

The character is a punctuation.
The character is not a punctuation.

在上面的程式中,兩個寬字元分別宣告為 a 和 b。字元檢查傳遞的字元是否是標點符號。

wint_t a = '!';
wint_t b = 'a';
if(iswpunct(a))
printf("The character is a punctuation.");
else
printf("\nThe character is not a punctuation.");
if(iswpunct(b))
printf("\nThe character is a punctuation.");
else
printf("\nThe character is not a punctuation.");

更新於:2020 年 6 月 26 日

132 次瀏覽

開始您的事業

透過完成課程獲得認證

開始學習
廣告
© . All rights reserved.