strrev(): String Reverse in C Programming

String handling function strrev() is used to reverse string in C programming language. Function strrev(str1) reverses the content of string str1.

strrev() Syntax


strrev(string);

strrev() Program


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

int main()
{
	char name[40];
	
	printf("Enter your name: ");
	gets(name);
	
	strrev(name);
	
	printf("Reversed name is: %s", name);
	
  return 0;	
}

strrev() Program Output


Enter youe name: Jenny↲
Reversed name is: ynneJ

Note: ↲ indicates ENTER is pressed.