The strupr( ) function is used to converts a given string to uppercase.
Syntax:
char *strupr(char *str);
Parameter:
- str: This represents the given string which we want to convert into uppercase.
Returns: It returns the modified string obtained after converting the characters of the given string str to uppercase.
Time Complexity: O(n)
Auxiliary Space: O(1)
Below programs illustrate the strupr() function in C:
Example 1:-
c
#include<stdio.h>
#include<string.h>
int main()
{
char str[ ] = "geeksforgeeks is the best" ;
printf ( "%s\n" , strupr (str));
return 0;
}
|
Output:
GEEKSFORGEEKS IS THE BEST
Example 2:-
c
#include<stdio.h>
#include <string.h>
int main()
{
char str[] = "CompuTer ScienCe PoRTAl fOr geeKS" ;
printf ( "Given string is: %s\n" , str);
printf ( "\nstring after converting to the uppercase is: %s" , strupr(str));
return 0;
}
|
Output:
Given string is: CompuTer ScienCe PoRTAl fOr geeKS
string after converting to the uppercase is: COMPUTER SCIENCE PORTAL FOR GEEKS
Note : This is a non-standard function that works only with older versions of Microsoft C.
Last Updated :
23 Jun, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...