I read some where that recursion of main() is not allowed in c++ but when i tried it ran without any error
#include<iostream>
using namespace std;
int i=10;
int main()
{
if(i==1)
{
cout<<i;
return 0;
}
i--;
main();
}
Calling
mainexplicitly is undefined behavior, anything can happen (including appear to work).C++03 3.6.1
The compiler (as all undefined behavior goes) is not required to provide a diagnostic, nor is the runtime required to crash.