Recursion and static variables

Viewed 7351

So I was preparing for an entrance exam here in India when I came across this piece of C code

#include <stdio.h>
int main(void) {
    static int i = 4;
    if (--i) {
        main();
        printf("%d", i);
    }
}

I thought the printf statement never gets executed and the output will be blank. But I saw the answer to be 0000 and that this happens due to the static keyword with the int.

Can anyone explain why the printf executes or is that guy wrong?

5 Answers
Related