C/C中的towupper()函数++

这个 towupper() 是C/C++中的一个内置函数,用于将给定的宽字符转换为大写。它是在 cwctype C++的头文件。

null

语法 :

wint_t towupper( wint_t ch )

参数 :该函数接受一个强制参数 中国 它指定了我们必须转换成大写的宽字符。

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

  • 如果ch有大写版本,则会将其转换为大写版本。
  • 如果不是,则不会发生修改。

下面的程序说明了上述功能。

方案1 :

// Program to illustrate
// towupper() function
#include <cwchar>
#include <cwctype>
#include <iostream>
using namespace std;
int main()
{
wchar_t str[] = L "GeeksforGeeks" ;
wcout << L "The uppercase version of ""
<< str << L "" is " ;
for ( int i = 0; i < wcslen(str); i++)
// Function to convert the character
// into the uppercase version, if exists
putwchar(towupper(str[i]));
return 0;
}


输出:

The uppercase version of "GeeksforGeeks" is GEEKSFORGEEKS

方案2 :

// Program to illustrate
// towupper() function
#include <cwchar>
#include <cwctype>
#include <iostream>
using namespace std;
int main()
{
wchar_t str[] = L "hello Ishwar 123!@#" ;
wcout << L "The uppercase version of ""
<< str << L "" is " ;
for ( int i = 0; i < wcslen(str); i++)
// Function to convert the character
// into the uppercase version, if exists
putwchar(towupper(str[i]));
return 0;
}


输出:

The uppercase version of "hello Ishwar 123!@#" is HELLO ISHWAR 123!@#

© 版权声明
THE END
喜欢就支持一下吧
点赞7 分享