Mark McIntyre said:
All of them, probably.
Because you have forgotten to #include stdio.h, and so the behaviour
is undefined. include the header and try again.
It's true that calling printf without a '#include <stdio.h>' (or a
declaration for printf) invokes undefined behavior, but in practice
it's highly unlikely that that explains the behavior he's seeing.
Note that the programme will continue indefinitely, or until you run
out of memory.
Assuming the '#include <stdio.h>' is added, there are three
possibilities I can think of:
1. The bottomless recursion will cause the program to run out of
memory after some number of calls. It will print the value of i
before each call; the last value printed will *probably* give you an
idea of how many calls occurred. However, running out of memory
invokes undefined behavior (terminating the program is common, but not
guaranteed), so there's no way to be certain. If you see different
numbers on successive invocations, it can be for any number of
reasons. The program may have different amounts of memory available
for whatever reason, or different amounts of output may have been
buffered but not yet displayed when the program crashed. (Unless you
call fflush(stdout) after each printf, you may not see all the
output.)
2. 'i' could reach INT_MAX before the program runs out of memory. At
this point, 'i++' invokes undefined behavior. Wrapping around to
INT_MIN is a common result, but it's not guaranteed. If it does
simply wrap around, the program will continue running until it runs
out of memory; see above.
2. The compiler may be smart enough to recognize the tail recursion,
transforming the recursive call into an infinite loop that doesn't
consume extra memory on each call. When 'i' reaches INT_MAX, the next
'i++' will invoke undefined behavior; see above. If the program
continues after this, it will probably keep running until you kill it.