Hi all.
Can someone please explain how this program works?
1. How are multiple instances of c preserved? Where are the multiple values stored?
2. How can putchar() print out all the multiple values of c without some type of loop? How is it accessing the values of c?
I don't know how this can be done without some type of array. Very baffling. Thanks in advance.
Output.Code:#include <stdio.h> void wrt_it(void); int main(void) { printf("Input a line: "); wrt_it(); printf("\n\n"); return 0; } void wrt_it(void) { int c; if((c = getchar()) != '\n') { wrt_it(); } putchar(c); }
Code:Input a line: Hello World dlroW olleH



9Likes
LinkBack URL
About LinkBacks



-i am just saying it for future use 
I think you're confusing static with const. static is kind of the swiss army knife of C, but here it is mutable and static would only increase the lifetime of 'c`.