Thursday, July 5, 2018

C Reverse String: strrev()

The strrev(string) function returns reverse of the given string. Let's see a simple example of strrev() function.






#include<stdio.h>
#include <string.h>
int main(){
char str[20];
printf("Enter string: ");
gets(str);//reads string from console
printf("String is: %s",str);
printf("\nReverse String is: %s",strrev(str));
return 0;
}



Output:

Enter string: rama

String is: rama

Reverse String is: amar




Instagram



No comments:

Post a Comment