STRREV(3pub) | C Programmer's Manual | STRREV(3pub) |
strrev - reverse a string in place
#include <publib.h> char *strrev(char *str);
strrev reverses the argument string in place, i.e., it swaps the ith character from the beginning with the ith character from the end.
strrev returns its argument.
Reversing "dlrow, elloh" would be done like the following.
This would output "hello, world". Note that using the string literal as the argument would be an error, since it is not allowable to modify string literals.
char str[] = "dlrow, elloh"; puts(strrev(str));
Does not automatically detect palindromes, nor automatically return without doing anything.
Lars Wirzenius (lars.wirzenius@helsinki.fi)
C Programmer's Manual | Publib |