ฟังก์ชัน towupper() แปลงตัวอักษรกว้าง (wide character) ให้เป็นตัวพิมพ์ใหญ่ (uppercase) ประกาศอยู่ใน cwctype (C++) หรือ ctype.h (C) หากตัวอักษรเป็นตัวพิมพ์ใหญ่อยู่แล้ว จะไม่มีการเปลี่ยนแปลง
รูปแบบไวยากรณ์
wint_t towupper(wint_t ch)
ตัวอย่าง
#include <cwchar>
#include <cwctype>
#include <iostream>
using namespace std;
int main() {
wchar_t s[] = L"hello world!";
wcout << L"The uppercase string is ";
for (int i = 0; i < wcslen(s); i++)
putwchar(towupper(s[i]));
return 0;
}ผลลัพธ์
The uppercase string : HELLO WORLD!