recursion of main
c++, recursion
Solution
Calling `main` explicitly is undefined behavior, anything can happen (including appear to work).
C++03 3.6.1
3) The function main shall not be used within a program. [...]
The compiler (as all undefined behavior goes) is not required to provide a diagnostic, nor is the runtime required to crash.
Problem
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(); } ```