What is iswupper() in C?

iswupper() is a built-in function defined in the <wctype> header in C.

The function checks whether or not the given wide character is an uppercase letter. This check is specific to the current locale being used.

Syntax

The function prototype:

int iswupper(std::wint_t ch);

iswupper() returns non-zero if the input wide character is in uppercase. Otherwise, the function returns zero.

Wide characters

A wide character has a size greater than the traditional 8-bit character.

A wide string literal is prefixed by L.

The iswupper() function

Code

/* iswlower example */
#include <stdio.h>
#include <stddef.h>
#include <wctype.h>
int main ()
{
int i=0;
//wide string literal -- all UPPERCASE
wchar_t str[] = L"HeLlO WoRlD!";
//wide char for input
wchar_t c;
//loop to iterate over each char in str
while (str[i])
{
c = str[i];
if (iswupper(c))
printf("%c --> UPPERCASE\n", c);
else
printf("%c --> not uppercase\n", c);
i++;
}
return 0;
}

Free Resources

Copyright ©2024 Educative, Inc. All rights reserved