Pages

Friday 4 July 2014

C – strrev() function

  • strrev( ) function reverses a given string in C language. Syntax for strrev( ) function is given below.
char *strrev(char *string);
  • strrev( ) function is non standard function which may not available in standard library in C.

Example program for strrev() function in C:

  • In below program, string “Hello” is reversed using strrev( ) function and output is displayed as “olleH”.
#include<stdio.h>
#include<string.h>

int main()
{
   char name[30] = "Hello";

   printf("String before strrev( ) : %s\n",name);

   printf("String after strrev( )  : %s",strrev(name));

   return 0;
}

 Output:


String before strrev( ) : Hello
String after strrev( )     : olleH

0 comments:

Post a Comment