C++ iswupper()

The iswupper() function in C++ checks if the given wide character is a uppercase character or not.

The iswupper() function is defined in <cwctype> header file.

iswupper() prototype

int iswupper(wint_t ch);

The iswupper() function checks if ch is a uppercase character i.e one of the following:

A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z.

iswupper() Parameters

  • ch: The wide character to check.

iswupper() Return value

  • The iswupper() function returns non zero value if ch is an uppercase character.
  • It returns zero if ch is not an uppercase character.

Example: How iswupper() function works?

#include <cwctype>
#include <iostream>
#include <clocale>
using namespace std;

int main()
{
	setlocale(LC_ALL, "en_US.UTF-8");
	
	wchar_t ch1 = L'\u03a0';
	wchar_t ch2 = L'\u03c0';
	
	wcout << L"iswupper(" << ch1 << ") returned " << boolalpha << (bool)iswupper(ch1) << endl;
	wcout << L"iswupper(" << ch2 << ") returned " << boolalpha << (bool)iswupper(ch2) << endl;
	
	return 0;
}

When you run the program, the output will be:

iswupper(Π) returned true
iswupper(π) returned false