Skip to content
Related Articles

Related Articles

Improve Article

strupr() function in c

  • Last Updated : 28 Sep, 2018
Geek Week

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.

Take a step-up from those “Hello World” programs. Learn to implement data structures like Heap, Stacks, Linked List and many more! Check out our Data Structures in C course to start learning today.



My Personal Notes arrow_drop_up
Recommended Articles
Page :