//translate "I am a student" to "tneduts a ma I" void reverse(char *a, char *b) { int i, j; i = 0; while (a[i] != '\0') { ++i; } b[i] = '\0'; --i; for (j = 0; j <= i; ++j) { b[j] = a[i-j]; } } //translate "I am a student" to "student am I" void reverse(char *a, char *b) { int i, j, p; i = 0; j = 0; while (a[i] != '\0') { ++i; } for (--i; i >= 0; --i) { if (a[i] == 32) { p = i+1; while (a[p] != 32 && a[p] != '\0') { b[j++] = a[p++]; } b[j++] = (i == 0 ? '\0' : 32); } if ( 0 == i) //cope with the final word { p = i; while (a[p] != '\0' && a[p] != 32) { b[j++] = a[p++]; } b[j++] = (i == 0 ? '\0' : 32); } } }