All the same... we know that int main (void) works correctly everywhere but there is no guarantee that empty parenthese will.
That said, the debate is interresting.
All the same... we know that int main (void) works correctly everywhere but there is no guarantee that empty parenthese will.
That said, the debate is interresting.
Now I am one to use 'int main(void)' as well, however the purpose of the standard is to ensure that it will work everywhere. If you wind up running into a compiler that won't accept 'int main()' then you have met a non-compliant compiler and should probably get a new one.
....or I guess you could always get a job in India.
As I noted in post #15, this feature where empty parentheses in function definition => no parameters is from C89. AndrewHunter just happened to quote from C99, which I deduced by the clause number. In fact, C99 marks the identifier list feature as obsolescent, though the draft of the next version of C that I have at hand retains it. Consequently...Originally Posted by CommonTater
We don't know that int main(void) works correctly everywhere (and in fact we know that it doesn't: freestanding implementations), and if it does, then int main() will.Originally Posted by CommonTater
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
OKAY GUYS.... I'm a bit confused. Which should I use now?
Just use:
Code:int main(void)
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Seldom have I ever seen such a truly simple point so totally bemuddled, only to arrive right back at the original suggestion...
Yes, use int main (void)