strrev()
is a non-standard C library function, sometimes found in <string.h>
, that is used to reverse a string. For instance,
‘coffee’, when passed to the function, will output ‘eeffoc.’
Note: Being non-standard means that
strrev()
may not be available. So, you may have to write your own function to reverse a string.
The function is defined as:
char *strrev(char *str);
The usage of strrev()
is illustrated below:
#include<stdio.h>#include<string.h>int main() {char str[20] = "coffee";printf("String before strrev(): %s\n",str);strrev(str);printf("String after strrev(): %s\n",str);return 0;}
Output:
eeffoc
Free Resources