The strrev() function is a built-in function in C and is defined in string.h header file. The strrev() function is used to reverse the given string.
Syntax:
char *strrev(char *str);
Parameter:
- str: The given string which is needed to be reversed.
Returns: This function returns the string after reversing the given string.
Note: This is a non-standard function that works only with older versions of Microsoft C.
Below programs illustrate the strrev() function in C:
Example 1:-
// C program to demonstrate // example of strrev() function #include<stdio.h> #include<string.h> int main() { char str[50] = "geeksforgeeks"; printf("The given string is =%s\n",str); printf("After reversing string is =%s",strrev(str)); return 0; } |
chevron_right
filter_none
Output:
The given string is =geeksforgeeks After reversing string is =skeegrofskeeg
Example 2:-
// C program to demonstrate // example of strrev() function #include<stdio.h> #include<string.h> int main() { char str[50] = "123456789"; printf("The given string is =%s\n",str); printf("After reversing string is =%s",strrev(str)); return 0; } |
chevron_right
filter_none
Output:
The given string is = 123456789 After reversing string is = 987654321
Recommended Posts:
- arc function in C
- strtod() function in C/C++
- iswdigit() function in C/C++
- vwprintf() function in C/C++
- vswscanf() Function in C/C++
- iswupper() function in C/C++
- putwchar() function in C/C++
- iswlower() function in C/C++
- Address of a function in C or C++
- iswcntrl() function in C/C++
- towctrans() function in C/C++
- strlwr() function in C
- fegetexceptflag() function in C/C++
- wmemcpy() function in C/C++
- wctrans() function in C/C++
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



