[英]Library function for reversing the string
Is there alternative for strrev()
in C? 在C语言中,
strrev()
是否可以替代? 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 ie reverse<>
is not working in C. 据我所知,操作可以由用户自定义功能可以轻松实现,但是我正在寻找一个图书馆alternative.Precisely有一些功能需要例如RINDEX (等同于
strrchr()
这是在Perl更常见,但在GCC-仍然有效4.3.4,我很想知道是否有类似strrev()
东西,因为perl中的通用反转函数,即reverse<>
在C语言中不起作用。
Compiler specification: [C (gcc-4.3.4)] 编译器规范:[C(gcc-4.3.4)]
Thanks, 谢谢,
PS:I am aware of C++'s STL reverse but my question is strictly about C. PS:我知道C ++的STL相反,但是我的问题严格是关于C的。
As far as I know, there is no such a function in C standard libraries. 据我所知,C标准库中没有这样的功能。 If you don't mind using C++, there is
reverse
template function in algorithms
. 如果您不介意使用C ++,则
algorithms
有reverse
模板功能。
1 .The strrev you are aware about is: 1。您知道的strrev是:
Using Loops 使用循环
2 . 2 。 Refer this link: http://fresh2refresh.com/c-programming/c-strings/c-strrev-function/
请参考以下链接: http : //fresh2refresh.com/c-programming/c-strings/c-strrev-function/
3 .In Turbo C the strrev() library function is available. 3。在Turbo C中 , strrev()库函数可用。
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
printf("%s",strrev("string"));
getch();
return 1;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.