Skip to main content

Reverse a String Using strrev in C

1 min read Updated June 30, 2026
Share:
On this page (7sections)

About this program

This is an example program in c string example programs. Read the concept first: C Strings in C Programming, then study the code and output below.

Definition:

  • strrev() is a default function in C programming which can be used to reverse a string.
  • The input to this function should be the character array of the string to be reversed.

Syntax:

strrev(character array);

Example Program for Reverse A String Using strrev

/*  Example Program For Example Program forReverse A String Using strrev In C Programming Language
    little drops @ thiyagaraaj.com
    Coded By:THIYAGARAAJ MP             */

// Header Files
#include<stdio.h>
#include<conio.h>
#include <string.h>

//Main Function
int main()
{
    // Variable Declaration
    char charArray[100];

    //Get Input Value
    printf("Enter the string to be reversed : ");
    gets(charArray);

	strrev(charArray);
    printf("String after reversal is : %s",charArray);
	
    // Wait For Output Screen
    getch();

     //Main Function return Statement
     return 0;
}

Output:

Enter the string to be reversed : reverse
String after reversal is : esrever

Learn the concept first, then study the code:

Frequently Asked Questions

What does this C program do?
It is a C example program that demonstrates Reverse a String Using strrev, including the complete source code and the expected sample output.
How do I compile and run this C program?
Save the code in a `.c` file, compile it with `gcc filename.c -o program`, then run it with `./program` (or `program.exe` on Windows).
What concepts does this example use?
This example uses arrays and reading user input, illustrating a common pattern in C programming.

Related Tutorials

Search tutorials