>void main is acceptable
The language standard explicitly states that main must return an int. This has always been the case, except in the past the language has been imprecise enough for some to misinterpret it. Some compilers support void main, but only to cater to stupid people who don't know what language they're using.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
read
http://homepages.tesco.net/~J.deBoynePollard/FGA/legality-of-void-main.html
Unfortunetly there is a valid claim to using void main(). It's bad practice, but does; technically, follow the standard (the specific standard mentioned in that article).
Been there, done that. I like this :
Even if your compiler accepts "void main()" avoid it, or risk being considered ignorant by C and C++ programmers.
"Hey, boss, the following code may or may not work -- it's behavior is unspecified*!"
*behavior where two or more possibilities exist and no further requirements on which is chosen in any instance
[edit]Follow some of the links and find that corrections have been made. Or that fun restrictions apply:If you declare main or wmain as returning void, you cannot return an exit code to the parent process or operating system using a return statement; to return an exit code when main or wmain are declared as void, you must use the exit function.
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
i need your help.is it possible to give a solution to the following problem.
Store random numbers into two-dimensional array of 6 * 6 and interchange first 3 rows with last three rows.
i would be grateful to hear from you soon.
thank you in advance.
Since this has nothing to do with this thread, it would have been better to have started a new one. Of course it is possible -- please post your initial attempt (and please use code tags).
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
>does; technically, follow the standard
Technically, no. Technically, the standard allows for non-portable extensions, but doesn't specify those extensions in any way. Therefore, void main does not follow the standard. It only has the potential for implementation-defined behavior rather than undefined behavior if the implementation documents it.
Your argument could be applied to any language or library extension.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401