UncleCoder.com

UncleCoder.com

Free programming examples and instructions

C program to study 'strrev()' string function

C program for how to reverse a string using strrev() function

by Krishna viswambharan


Posted on 28 Sep 2017 Category: C Views: 178

Edited on 19 Jan 2018


C program to study 'strrev()' string function

In this article, we will see how to reverse the input string using the string function strrev() . This string function is defined in the <string.h> header file

strrev( ) function reverses a given string in C language. Syntax for strrev( ) function is given below.

char *strrev(char *string);

In the below program , the given string  is reversed using the string function strrev().  C code for the program is written as below.

#include <stdio.h>
#include <string.h>
#include <conio.h>
 
void main()
{
   char str[100];
 
   printf("Enter input string1 :");
   gets(str);
 
   strrev(str);
 
   printf(“Reversed string :%s”,str);
   getch();
}

output



Leave a Comment:


Advertisement