### strrev -- Reverse String

Format

>     #include <string.h>
>     char *strrev(char *string);

Language Level: Extension
strrev reverses the order of the characters in the given string. The ending null character (\0) remains in place.

Return Value
strrev returns a pointer to the altered string. There is no error return value.

Example
This example determines whether a string is a palindrome. A palindrome is a string that reads the same forward and backward.

    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>

    int palindrome(char *string)
    {
       char *string2;

       /* Duplicate string for comparison                                         */

       if (NULL == (string2 = strdup(string))) {
          printf("Storage could not be reserved for string\n");
          exit(EXIT_FAILURE);
       }

       /* If result equals 0, the string is a palindrome                          */

       return (strcmp(string, strrev(string2)));
    }

    int main(void)
    {
       char string[81];

       printf("Please enter a string.\n");
       scanf("%80s", string);
       if (palindrome(string))
          printf("The string is not a palindrome.\n");
       else
          printf("The string is a palindrome.\n");
       return 0;

       /*********************************************
          Sample output from program:

          Please enter a string.
          level
          The string is a palindrome.
          ... or ...
          Please enter a string.
          levels
          The string is not a palindrome.
       *********************************************/
    }

strcat -- Concatenate Strings
strcmp -- Compare Strings
strcpy -- Copy Strings
strdup -- Duplicate String
strnset - strset -- Set Characters in String
<string.h>