The recursive main()

I didn’t think that way, but it turns out that main() function can be used recursively in C. So, for instance, the given code is completely valid and runs on any GCC compiler.

#include
int a = 10;
main()
{
while(a)
{   
    a–;
    printf(“%d\n”,a);
    main();  // Here it is
}
}
I don’t know how useful this maybe, but it can be handy for some real nice MCQs related to code obfuscation.  

Leave a comment