Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
Is main a registered word
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Keith Thompson, post: 2497601"] The first clause, before the ';', says that returning a value from main() is equivalent to calling exit() with that same value. This applies only to the initial call, and only if main's return type is compatible with int. The second call, after the ';', says that reaching the '}' at the end of main() is equivalent to returning a value of 0. I don't see a contradiction, but I do seem an ambiguity. As Harald pointed out, there are two conditions stated in the first clause: that the return type is compatible with int, and that the call is the initial call. The first condition (return type compatible with int) logically *should* apply to the second clause (falling off the end returns 0). The second condition (initial call) logically may or may not. The way the sentence is structured, I don't think that *either* condition applies to the second clause -- but if that were the intent, it would have made more sense to write two sentences rather than using a semicolon. It doesn't matter much to me as a programmer; I have no intention of taking advantage of the ability to fall off the end of main() without an explicit exit() or return statement. And an implementer can meet the requirements, whatever they may be, by always returning 0 when a program reaches the closing "}" of main(), whether it's the initial call or not (that's probably the easiest thing to do anyway). But it would be nice to know exactly what's intended. I'll post to comp.std.c. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
Is main a registered word
Top