Name

toupper - convert letter to upper case

Library

libc.lib

Synopsis

  #include <ctype.h>
  int toupper (int c);

Return values

If the argument is a lower-case letter, the toupper function returns the corresponding upper-case letter if there is one; otherwise the argument is returned unchanged. The towupper function should be used instead.

Detailed description

The toupper function converts a lower-case letter to the corresponding upper-case letter. For single character representations, the value of the argument is representable as an unsigned char or the value of EOF. The functionality of this API is independent of the program’s current locale.

Examples

#include<ctype.h> //toupper()
#include<stdio.h> //printf()
int test_toupper()
{
   struct st
   {
     int input;
     int output;
   };
   struct st  arr[]=
   {
   { ’q’, ’Q’ },
   { ’G’ , ’G’ },
   { ’9’ , ’9’ },
   { ’%’ , ’%’ },
   { ’\t’ , ’\t’ },
   };
   int i = 0;
   int size = 5;
   for( i=0; i<size; i++)
   {
      int ret = toupper(arr[i].input);//call to the API with the chars in arr[]
      if( ret != arr[i].output )
      {
          printf("\n%c cannot convert ", arr[i].input);
      }
      else
      {
          printf("\n%c ", arr[i].output);
      }
   }
printf("\n");
}

         

Output

q
G
9
%

         

See also

isupper, towupper, defns

Feedback

For additional information or queries on this page send feedback

© 2005-2007 Nokia

Top