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 main explicitly is undefined behavior, anything can happen (including appear to work).
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With