strrev in C Programming

The C strrev function is a String Function, used to reverse the given string. The syntax of the strrev is

char *strrev(char *str1);

or we can write this string reverse function as:

strrev(str1);

strrev in C Example

The string strrev function used to reverse the user-specified string. This program will help you to understand the string strrev with multiple examples.

TIP: You have to include the Programming #include<string.h> header before using this strrev String Function.

/* string strrev in C programming Example */

#include <stdio.h> 
#include<string.h>

int main()
{
	char str[] = "C Programming Tutorial";
		
	char str1[] = "C language";
	char str2[] = "Tutorial Gateway";
	char str3[] = "C Programming World";
	char str4[] = "TutorialGateway";
			
 	printf("\n Reverse String is = %s", strrev(str));
 	printf("\n Reverse String is = %s", strrev(str1));
 	printf("\n Reverse String is = %s", strrev(str2));
 	printf("\n Reverse String is = %s", strrev(str3)); 	
  	printf("\n Reverse String is = %s", strrev(str3)); 		
}
String strrev in C programming Example 1

String strrev Example 2

This program allows the user to enter their string. Next, it is going to use the strrev function to reverse the user-specified string.

/* string strrev in C programming Example */

#include <stdio.h> 
#include<string.h>

int main()
{
	char str[100];
 
	printf("\n Please Enter any String to Reverse  : ");
	gets(str);	
	
 	printf("\n Reverse String is = %s", strrev(str));
	
}
Please Enter any String to Reverse  : Tutorial Gateway

Reverse String is = yawetaG lairotuT