Is the strrev() function not available in Linux?
c, string
Solution
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;
}
Problem
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()`?