Skip to content
Related Articles

Related Articles

Improve Article

strupr() function in c

  • Last Updated : 28 Sep, 2018

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.

Below programs illustrate the strupr() function in C:



Example 1:-




// c program to demonstrate
// example of strupr() function.
#include<stdio.h>
#include<string.h>
  
int main()
{
    char str[ ] = "geeksforgeeks is the best";
    //converting the given string into uppercase.
    printf("%s\n", strupr (str));
    return  0;
}

Output:

GEEKSFORGEEKS IS THE BEST

Example 2:-




// c program to demonstrate
// example of strupr() function.
  
#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.

Want to learn from the best curated videos and practice problems, check out the C Foundation Course for Basic to Advanced C.



My Personal Notes arrow_drop_up
Recommended Articles
Page :