C library function - toupper()



Description

The C library function int toupper(int c) converts lowercase letter to uppercase.

Declaration

Following is the declaration for toupper() function.

int toupper(int c);

Parameters

  • c − This is the letter to be converted to uppercase.

Return Value

This function returns uppercase equivalent to c, if such value exists, else c remains unchanged. The value is returned as an int value that can be implicitly casted to char.

Example

The following example shows the usage of toupper() function.

#include <stdio.h>
#include <ctype.h>

int main () {
   int i = 0;
   char c;
   char str[] = "Tutorials Point";
   
   while(str[i]) {
      putchar (toupper(str[i]));
      i++;
   }
   
   return(0);
}

Let us compile and run the above program to produce the following result −

TUTORIALS POINT
ctype_h.htm
Advertisements