#include<iostream>
using namespace std;
int main()
{
cout << "hello world";
}
Shouldn't I get a compiler warning? return 0;
does not exist.
#include<iostream>
using namespace std;
int main()
{
cout << "hello world";
}
Shouldn't I get a compiler warning? return 0;
does not exist.
main is special, this is specially allowed by the standard and the function is equivalent to having "return 0;" at the end. main is the only such function that has an assumed return value like this.
http://eel.is/c++draft/basic.start.main#5
If control flows off the end of the compound-statement of main, the effect is equivalent to a return with operand 0 (see also [except.handle]).
I think this also depends on the IDE you’re using. I found that using codeblocks gives a warning while things work normally with Virtual Studio