strrev() function in C
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
- fegetenv() function in C/C++
- wctrans() function in C/C++
- wmemcpy() function in C/C++
- clock() function in C/C++
- strnset() function in C
- time() function in C
- wcsncat() function in C/C++
- wcstol() function in C/C++
- wcstod() function in C/C++
- wcsrtombs() function in C/C++
- wcsncmp() function in C/C++
- fegetexceptflag() function in C/C++
- vswprintf() function in C/C++
- wcrtomb() 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.



