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


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!

更新時間: 2020-06-24

183 次瀏覽

開啟你的 職業生涯

完成課程並獲得認證

開始學習
廣告
© . All rights reserved.