Wait are we talking C98, C99, or ISO standards?
Wait are we talking C98, C99, or ISO standards?
>>Yet the standard is clear that the ways to declare main are as the following
You'll notice that it also provides for anything equivalent to the two definitions provided, which the section I quoted shows that
is equivalent.Code:int main() { /* ... */ }
>>So why the fuss?
It's a trivial matter, I agree, but I don't like everyone calling me wrong when I'm not.
>>Wait are we talking C98, C99, or ISO standards?
All of them. This is one rule that hasn't changed since C89.
Kampai!
I think they are referring to the use ofOriginally Posted by Sake
being the same asCode:int main(int argc char *argv[])
and the like - that is what I gather from the footnote. But as to the form of main without command line arguments,Code:int main(int argc char **argv)
~/5.1.2.2.1
Program startup
1 The function called at program startup is named main. The implementation declares no prototype for this function. It shall be defined with a return type of int and with no parameters:
Code:int main(void) { /* ... */ }
Last edited by kermit; 02-13-2005 at 10:23 AM.
Since your misunderstanding won't break anything, you can believe what you want to. But if you want to further your understanding of C, feel free to post the following question on comp.std.c.
People who are much smarter than me (including those who actually helped write the standard) have debated this before and the consensus was that the two are valid, equivalent, and conforming.Code:What is the difference between int main() { return 0; } and int main(void) { return 0; } ?
Kampai!
>>feel free to post the following question on comp.std.c.
No thanks, I know how to browse usenet with Google, so I can look it up myself if I choose.
Regarding misunderstanding - I guess those smart people who wrote the standard ought to polish it up a bit, particularly section 5.1.2.2.1 - that way people who are not smart, and cannot very well comprehend what they are reading in the standard, might have a better chance at learning something about the language. Perhaps you could post something like this to comp.std.c
Clear enough?Hey smart people - please rewrite section 5.1.2.2.1 so it is more understandable.
thanx
~/
Last edited by kermit; 02-13-2005 at 11:18 AM.
>>No thanks, I know how to browse usenet with Google, so I can look it up myself if I choose.
But you choose not to because you still think you're right and I'm not? People here are almost as stubborn as I am.
>>Clear enough?
The standard was written to be precise for implementors, not comprehensible for the average programmer. If every little detail were explained then the standard would grow exponentially. To be perfectly frank, if you read it enough, you learn the writing style and it's easier to make sense of things. And of course, comp.std.c is a fine place to get clarification if there's any doubt.
Kampai!