A Program to Reverse String Using strrev()

In this example, we are giving a program to reverse a string using the strrev() function.


Program to to reverse a string using the strrev() function:

  1. #include <stdio.h>
  2. #include <string.h>
  3. int main() {
  4. char str[100];
  5. printf("Enter a string to reverse: ");
  6. gets(str);
  7. strrev(str);
  8. printf("Reverse of the string: %s\n",str);
  9. return 0;
  10. }

Output:

Enter a string to reverse: abc
Reverse of the string: cba