C strrev() and strlwr() function in C language

The strrev() and strlwr() functions are used in C programming to reverse a string and make lowercase string respectively. strrev() function returns the reverse string while strlwr() function returns the string after converting lowercase of all its characters.

In this article we will see some programs using strrev() and strlwr() string functions.

strrev() function in C, reverse string

strrev() function can reverse a string. This string function is used to reverse our given string and it returns the reverse string. See the C program bellow which we have used strrev() function.

// strrev() function in C, reverse string
#include<stdio.h>
#include <string.h>
int main(){
  char strg[30];

  printf("Enter a string to reverse it : ");
  gets(strg);

  printf("You have entered : %s\n",strg);

  printf("\nReverse String is : %s\n",strrev(strg));

return 0;
}

Output of this reverse string program:

Enter a string to reverse it : competitive
You have entered : competitive

Reverse String is : evititepmoc

strlwr() function in C, lowercase string

The strlwr() function returns the same string converting all the characters in lowercase. We use this function when we need to make an entire string in lowercase. Here is the C program to make a lowercase string using strlwr() function.

// strlwr() function in C, lowercase string
#include<stdio.h>
#include <string.h>
int main(){
  char yourString[30];

  printf("Enter a string to make it lowercase : ");
  gets(yourString);

  printf("\nYou have entered : %s\n",yourString);
  printf("Lowercase String is : %s\n",strlwr(yourString));

 return 0;
}

Output of this lowercase string program:

strlwr() function in C, lowercase string