English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Online tools

O)

C Language Functions

C Language Arrays

C Language Pointers

C Language Strings

C language flow control

C language structure

C language file

C others

C language reference manual

C Standard Library <ctype.h>

C library function toupper() usage and example

If the parameter passed is a lowercase letter, the toupper() function will convert the lowercase letter to uppercase.

C toupper() function prototype

int toupper(int arg);

The toupper() function accepts a single parameter in integer form and returns an int type value.

Even if toupper() uses an integer as a parameter, the character is still passed to the function. Internally, the character is converted to the corresponding ASCII value for checking.

If the parameter passed is not a lowercase letter, it returns the same character passed to the function.It<ctype.h>

Defined in header files.

Example: C toupper() function
#include <stdio.h>
#include <ctype.h>
int main()
    {
    char c;
    c = 'm'; -> %c", c, toupper(c));
    //If the character passed to toupper() is not a lowercase character, it displays the same parameter passed.
    c = 'D';
    printf("\n%c -> %c", c, toupper(c));
    c = '9';
    printf("\n%c -> %c", c, toupper(c));
    return 0;
}

Output Result

m -> M
D -> D
9 -> 9

C Standard Library <ctype.h>