Subj : Re: Reverse words in a string (Another Interview question) To : comp.programming From : pete Date : Wed Oct 05 2005 02:50 pm Roger Willcocks wrote: > Okay, how about: > > #include > #include mem functions are among the string functions in C. In C, it's for string and memory functions like memcpy. > char* revstr(char* str, char* out) > { > char* end; > while (*str == ' ') str++; > end = str; > while (*end && *end != ' ') end++; > if (*end) { > out = revstr(end, out); > *out++ = ' '; > } > memcpy(out, str, end - str); > *(out += end - str) = 0; > return out; > } -- pete .