The string inversion function strrev is not a standard library function in C language. Many C language compilers do not provide support for it. For example, if you enter the shell command MAN 3 strlen in Linux, the screen will display,
STRLEN(3) Linux Programmer's Manual STRLEN(3)NAME strlen - calculate the length of a stringSYNOPSIS #include <string.h> size_t strlen(const char *s);DESCRIPTION The strlen() function calculates the length of the string s, excluding the terminating null byte ('\0').RETURN VALUE The strlen() function returns the number of characters in s.CONFORMING TO SVr4, 4.3BSD, C89, C99.SEE ALSO string(3), strnlen(3), wcslen(3), wcsnlen(3)COLOPHON This page is part of release 3.35 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://man7.org/linux/man-pages/.GNU 2011-09-28 STRLEN(3)
It tells you that the function implemented by strlen is calculate the length of a string, and # include <string. h> is required for reference. If you enter the man 3 strrev command, shell will tell you,
There are no entries on the strrev manual page in section 3rd.
Through the above operations, it is also verified that GCC does not provide support for strrev. Because it is a standard function, the compiler does not support it for a reason.
Strrev functions are not commonly used, but they are still available for digital conversion and encryption, because some compilers and VC for embedded platforms provide support for them. For compilers that do not support strrev functions, many netizens have provided a lot of valuable solutions. However, the source code provided by VC is extracted directly, which seems to be more efficient and portable, the following provides a classic implementation code:
Char * strrev (char * s) {/* H points to the S header */char * H = s; char * t = s; char ch; /* t points to the end of S */while (* t ++) {}; t --;/* offsets against T ++ */t --; /* skip the terminator '\ 0' * // * when h and T are not duplicated, exchange the characters they point to */while (H <t) {CH = * h; * H ++ = * t;/* H moves toward the end */* t -- = CH; /* t move to the header */} return (s );}