首页 > 文章列表 > 在C/C++中,towupper()函数

在C/C++中,towupper()函数

C/C编程 字符转换 towupper()函数
273 2023-08-31

函数 iswupper() 是 C/C++ 中的内置函数。它将宽字符转换为大写字符。 C++ 语言在“cwctype”头文件中声明,C 语言则在“ctype.h”头文件中声明。它采用单个字符,称为宽字符。如果字符是大写,则转换为大写,否则不发生任何修改。

以下是 C++ 语言中 towupper() 的语法,

wint_t towupper( wint_t ch );

这里是 C++ 语言中 towupper() 的示例,

示例

#include <cwchar>
#include <cwctype>
#include <iostream>
using namespace std;
int main() {
   wchar_t s[] = L"hello world!";
   wcout << L"The uppercase string":
   << L""is ";
   for (int i = 0; i < wcslen(s); i++)
   putwchar(towupper(s[i]));
   return 0;
}

输出

The uppercase string : HELLO WORLD!