void main or int main?!?

In c++, is using void main() even legal and if so, in what cases?

Just a note, I indeed have consulted a lot of websites regarding this and they all seem to say that
void main() in c++ is for dummies
. but my teachers and many friends say there is no problem with void main. but my compiler shows an error with void. and even if it is not a good practice, is it at least allowed in c++? I just want to close this topic once and for all.
Last edited on
In c++, is using void main() even legal


According to the standard, no.

Though some compilers still allow you to do it.

but my teachers and many friends say there is no problem with void main


They're wrong. It's non-standard.

but my compiler shows an error with void


That's because your compiler is following the standard -- as it should be.
thanks guys. I will straighten the guys out now! :)
Topic archived. No new replies allowed.