/* * Make a string in 'to' which is the same characters as in the string 'from' * but in the opposite order. The area pointed to by 'to' must be as large as * required to hold the string in 'from'. */ void reverse(char *from, char *to) { int len, i; /* find string length */ for (len = 0; from[len]; len++) ; /* copy, reversing */ for (i = 0; i < len; i++) to[len - i - 1] = from[i]; /* terminate target string */ to[len] = '\0'; } /* There are library functions to do some of the string operations above. */