在Linux中提供的strrev()函数呢? [英] Is the strrev() function not available in Linux?
本文介绍了在Linux中提供的strrev()函数呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试着用 strrev()
写code。我包括<文件string.h方式>
,但我依然收到未定义的引用`strrev错误
我发现 strrev()
没有手册页的。为什么?
不支持Linux strrev()
?
解决方案
正确的。使用可用的替代实现之一。
的#include<&string.h中GT;字符* strrev(字符*海峡)
{
字符* P1,P2 *; 如果(!STR ||!* STR)
返回海峡;
为(P1 = str中,P2 = STR +的strlen(STR) - 1; P2> P1,P1 ++,--p2)
{
* ^ P1 = * P2;
* P2 ^ = * P1;
* ^ P1 = * P2;
}
返回海峡;
}
块引用>I tried to write code using
strrev()
. I included<string.h>
but still I'm getting an "undefined reference to `strrev'" error.I found that
strrev()
doesn't have man page at all. Why?Doesn't Linux support
strrev()
?解决方案Correct. Use one of the alternative implementations available.
#include <string.h> char *strrev(char *str) { char *p1, *p2; if (! str || ! *str) return str; for (p1 = str, p2 = str + strlen(str) - 1; p2 > p1; ++p1, --p2) { *p1 ^= *p2; *p2 ^= *p1; *p1 ^= *p2; } return str; }
这篇关于在Linux中提供的strrev()函数呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文