/* str_rev: Reverse all characters in string */ #include #include #include #include char *str_rev(const char *s) { char *t = malloc(strlen(s)); strncpy(t, s, strlen(s)); const char *r = s + strlen(s) - 1; char *w = t; while (r >= s) { *w++ = *r--; } return t; } int main(int argc, char *argv[]) { for (int i = 1; i <= argc; i++) { char *t = str_rev(argv[i]); puts(t); } return 0; }