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.
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);
}
Output.
Code:
Input a line: Hello World
dlroW olleH