main() calling itself
I keep on reading that main() is not allowed to call itself, yet the following code works for me:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
#include <iostream>
int main(void)
{
using std::cout;
using std::cin;
int blub;
cout << "-1 to quit: ";
cin >> blub;
if (blub == -1)
{
cout << "Hurrah!" << std::endl;
return 0;
}
cout << "Another round!" << std::endl;
main();
}
|
Is my compiler allowing nonstandard behaviour? Speaking of which, could someone quote the standard on this, since I cannot find it online?
Topic archived. No new replies allowed.