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


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


iswlower()是C /C++中的内置函数,该函数检查给定的宽字符是否为小写字符。它在C++的cwctype头文件中定义。

用法

int iswlower(ch)

参数:该函数接受单个强制性参数ch,该参数指定宽字符,我们必须检查该字符是否为小写字符。


返回值:该函数返回两个值,如下所示。

  • 如果参数ch是小写字符,则返回非零值。
  • 如果不是小写字符,则返回0。

以下示例程序旨在说明上述函数。

程序1

// C++ program to illustrate 
// iswlower() function 
#include <cwctype> 
#include <iostream> 
using namespace std; 
  
int main() 
{ 
  
    wchar_t ch1 = 'a'; 
    wchar_t ch2 = 'A'; 
  
    // Function to check if the character 
    // is a lowercase character or not 
    if (iswlower(ch1)) 
        wcout << ch1 << " is a lowercase character "; 
    else
        wcout << ch1 << " is not a lowercase character "; 
    wcout << endl; 
  
    if (iswlower(ch2)) 
        wcout << ch2 << " is a lowercase character "; 
    else
        wcout << ch2 << " is not a lowercase character "; 
  
    return 0; 
}
输出:
a is a lowercase character 
A is not a lowercase character

程序2

// C++ program to illustrate 
// iswlower() function 
#include <cwctype> 
#include <iostream> 
using namespace std; 
  
int main() 
{ 
  
    wchar_t ch1 = 'q'; 
    wchar_t ch2 = '?'; 
  
    // Function to check if the character 
    // is a lowercase character or not 
    if (iswlower(ch1)) 
        wcout << ch1 << " is a lowercase character "; 
    else
        wcout << ch1 << " is not a lowercase character "; 
    wcout << endl; 
  
    if (iswlower(ch2)) 
        wcout << ch2 << " is a lowercase character "; 
    else
        wcout << ch2 << " is not a lowercase character "; 
  
    return 0; 
}
输出:
q is a lowercase character 
? is not a lowercase character


相关用法


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