Table of Contents

    strrev() Function in C: Reversing Strings

    strrev() Function in C: Reversing Strings

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

    Syntax

    char *strrev(char *string);

    Important Note

    strrev() function is non standard function which may not available in standard library in C.

    Program

    In below program, string Welcome to atnyla is reversed using strrev( ) function and output is displayed as alynta ot emocleW.

    
    #include<stdio.h>
    #include<string.h>
     
    int main()
    {
       char name[30] = "Welcome to atnyla";
     
       printf("String before strrev( ) : %s\n",name);
     
       printf("String after strrev( )  : %s \n",strrev(name));
     
       return 0;
    }
    

    Output

    String before strrev( ) : Welcome to atnyla
    String after strrev( )  : alynta ot emocleW
    Press any key to continue . . .