Julian V. Noble wrote:
[color=blue]
> herrcho wrote:[color=green]
>>
>> int main()
>> {
>> printf("Input a line: ");
>> wrt_it();
>> printf("\n\n");
>> return 0;
>> }
>>
>> void wrt_it()
>> {
>> int c;
>>
>> if (( c = getchar()) != '\n')
>> wrt_it();
>> putchar(c);
>> }
>>
>> the above is from 'A book on C'
>> and it says the function calls are stacked.
>>
>> i know what stack means. but don't understand how stack is related to
>> recursion.
>>
>> Could anyone explain to me about that ? and, why does the input
>> characters print reversely?[/color]
>
> Let me recommend my column on this subject from "Computing in
> Science and Engineering". Title is "Recurses!" Can be found at
>
>[/color]
http://www.phys.virginia.edu/classes...ogs/Cprogs.htm[color=blue]
>
> Basically, languages that implement recursion use stacks to pass
> parameters and return addresses when calling subroutines (or functions).
> How this is done, exactly, is left up to the implementer. But a stack
> of some sort must be used for recursion. (It may or may not be the cpu
> stack, depending on the cpu, etc.)
>[/color]
Dosen't Continuation Passing Style not use a stack? Or am I confused about
it?
--
Fifth Law of Procrastination:
Procrastination avoids boredom; one never has the feeling that
there is nothing important to do.