Richard said:
And I thought /I/ was being a little cruel. Consider just how fragile
recursion is, in this context. For example, what if the characters were
taken from ISO/IEC 9899:1999 in its entirety? What machine among you will
be able to recurse that deeply?
My DS-9000 could do it without filling its top-level cache. (-:
For any list being procesed by someone who needs to ask this
question, the scenario you posit seems improbable - and for
reasonable list sizes, I think it'd be a not-too-difficult and
instructive exercise - and hardly cruel.
Of course, it's also possible to count the list elements and
malloc an appropriate-sized array that could be filled backwards,
puts'd, and freed - I guess it'd all depend on whether the
exercise is intended to focus on memory management functions or
to explore solution techniques.
So, what does junky_fellow do if there isn't room to build this
horrendous string and malloc fails? Well, he could also consider
making a pass through the list for each character, moving the
stop point back by one element for each pass...