October 2004
Intermediate to advanced
336 pages
6h 27m
English
This function prints out the words in a sentence reversed. The function uses recursive calls to itself. The definition of words is any sequence of characters delimited by one or more spaces. The resulting printout should include only one space between words, with no spaces before the first word or after the last word. Therefore, the input string can have multiple spaces between words, or before and after the string, but the result should not preserve those.
The bug does not involve the stack potentially overflowing because of excessive recursion—assume that is not an issue.
For this example, the length of the string is ...
Read now
Unlock full access