1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include <stdio.h> #include <string.h> void main() { char s[20]; printf("input string ? "); scanf("%19s", s); int len = strlen(s); char *p = s, *q = s + (len - 1); char c; while (p < q) { c = *p; *p++ = *q; *q-- = c; } printf("%s\n", s); }