首頁  >  文章  >  後端開發  >  在C/C++中,iswpunct()函數的作用是判斷一個寬字元是否為標點符號

在C/C++中,iswpunct()函數的作用是判斷一個寬字元是否為標點符號

王林
王林轉載
2023-09-01 16:09:07996瀏覽

在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 = &#39;!&#39;;
   wint_t b = &#39;a&#39;;
   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 = &#39;!&#39;;
wint_t b = &#39;a&#39;;
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.");

以上是在C/C++中,iswpunct()函數的作用是判斷一個寬字元是否為標點符號的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:tutorialspoint.com。如有侵權,請聯絡admin@php.cn刪除