C Data Type Functions - C isupper






Determines if a character is an uppercase letter (A?Z).

Prototype

int isupper ( int c );

Parameter

This function has the following parameter.

c
Character to be checked, casted to an int, or EOF.

Return

A value different from zero (i.e., true) if indeed c is an uppercase alphabetic letter. Zero (i.e., false) otherwise.

Example


#include <stdio.h>
#include <ctype.h>
/*w  ww  . j  ava 2  s .c om*/
int main (){
  int i=0;
  char str[]="Test String.\n";
  char c;
  
  while (str[i]){
    c=str[i];
    if (isupper(c)) c=tolower(c);
    putchar (c);
    i++;
  }
  return 0;
} 

       

The code above generates the following result.





Example 2


#include <stdio.h>
#include <ctype.h>
#include <locale.h>
 //from   w ww.j a  v  a 2 s  .c  o  m
int main(void)
{
    unsigned char c = '\xc6';
    printf("In the default C locale, \\xc6 is %suppercase\n",
           isupper(c) ? "" : "not " );
    setlocale(LC_ALL, "en_GB.iso88591");
    printf("In ISO-8859-1 locale, \\xc6 is %suppercase\n",
           isupper(c) ? "" : "not " );
}

The code above generates the following result.