当前位置: 首页>>编程示例 >>用法及示例精选 >>正文


C++ Iswctype()用法及代码示例

在 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(宽字符类型)的返回类型。

返回值

如果 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.

相关用法


注:本文由纯净天空筛选整理自Sunidhi Bansal大神的英文原创作品 Iswctype() function in C++ STL。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。