C Language: toupper function
(Convert to Uppercase)
In the C Programming Language, the toupper function returns c as an uppercase letter.
Syntax
The syntax for the toupper function in the C Language is:
int toupper(int c);
Parameters or Arguments
- c
- The value to convert to an uppercase letter.
Returns
The toupper function returns c as an uppercase letter. If c is already uppercase, the toupper function returns c unchanged.
Required Header
In the C Language, the required header for the toupper function is:
#include <ctype.h>
Applies To
In the C Language, the toupper function can be used in the following versions:
- ANSI/ISO 9899-1990
toupper Example
Let's look at an example to see how you would use the toupper function in a C program:
/* Example using toupper by TechOnTheNet.com */ #include <stdio.h> #include <ctype.h> int main(int argc, const char * argv[]) { /* Define a variable and set it to 'b' */ int letter = 'b'; /* Display a lowercase 'b' */ printf("Uppercase '%c' is '%c'\n", letter, toupper(letter)); return 0; }
When compiled and run, this application will output:
Uppercase 'b' is 'B'
Similar Functions
Other C functions that are similar to the toupper function:
See Also
Other C functions that are noteworthy when dealing with the toupper function:
Advertisements