C toupper() Prototype
int toupper( int arg );
Function toupper() takes a single argument in the integer form and returns a value of type int
.
Even though, toupper() takes integer as an argument, character is passed to the function. Internally, the character is converted to its corresponding ASCII value for the check.
If the argument passed is other than a lowercase alphabet, it returns the same character passed to the function.
It is defined in <ctype.h> header file.
Example: C toupper() function
#include <stdio.h>
#include <ctype.h>
int main()
{
char c;
c = 'm';
printf("%c -> %c", c, toupper(c));
// Displays the same argument passed if other characters than lowercase character is passed to toupper().
c = 'D';
printf("\n%c -> %c", c, toupper(c));
c = '9';
printf("\n%c -> %c", c, toupper(c));
return 0;
}
Output
m -> M D -> D 9 -> 9