iswctype()函式在C++ STL中


在C++標準模板庫(STL)中,iswctype()函式用於檢查給定的寬字元是否具有由desc指定屬性。

Iswctype()是內建函式,其標頭檔案為“ctype.h”。

Iswctype()的語法如下

int iswctype(wint_t c, wctype_t desc);
iswctype ()
/ Checks whether whether c has the property specified by desc. /

概要

int iswctype(wint_t c, wctype_t desc);

引數

C − 檢查被強制轉換為wint_t整數型別的寬字元

Desc − 這是由wctype呼叫的值,wctype是一種標量型別,用作wctype(寬字元型別)的返回值。

返回值

如果c確實具有由desc標識的屬性,則為非零值(即為真)。否則為零(即為假)。

C中的ISWCTYPE()函式的程式

 即時演示

#include <stdio.h>
#include <wctype.h>
int main (){
   int i=0;
   wchar_t str[] = L"Test String.\n";
   wchar_t c;
   wctype_t check = wctype("lower");
   wctrans_t trans = wctrans("toupper");
   while (str[i]){
      c = str[i];
      if (iswctype(c,check)) c = towctrans(c,trans);
         putwchar (c);
         i++;
   }
   return 0;
}

輸出

如果執行上述程式碼,它將生成以下輸出 −

TEST STRING.

更新於:2020-01-30

瀏覽量45次

開啟你的職業生涯

完成課程認證

開始吧
廣告
© . All rights reserved.