开发者

Library function for reversing the string

开发者 https://www.devze.com 2023-02-11 17:16 出处:网络
Is there alternative for strrev() in C? I am interested in a function that does the same but it must be included in the standard library.

Is there alternative for strrev() in C? I am interested in a function that does the same but it must be included in the standard library.

I am aware that operation can be easily implemented by user defined function but I am looking for a library alternative.Precisely there are few functions take for example rindex (identical to strrchr()) which is more common in perl but still works in gcc-4.3.4,I am inquisitive to know if there is anything like that for strrev() since the common reversing function in perl i.e reverse<> is not working in C.

Compiler specification: [C (gcc-4.3.4)]

Thank开发者_Python百科s,

PS:I am aware of C++'s STL reverse but my question is strictly about C.


As far as I know, there is no such a function in C standard libraries. If you don't mind using C++, there is reverse template function in algorithms.


1 .The strrev you are aware about is:

Using Loops

2. Refer this link: http://fresh2refresh.com/c-programming/c-strings/c-strrev-function/

3.In Turbo C the strrev() library function is available.

#include<stdio.h>
#include<conio.h>
int main()
{
   clrscr();
   printf("%s",strrev("string"));
   getch();
   return 1;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号