Are you serious?Quote:
If you don't need argc and argv?Quote:
So why do people continue to use main() and main(void)? without int
What do argc, and argv have to do with main's return type?
Printable View
Are you serious?Quote:
If you don't need argc and argv?Quote:
So why do people continue to use main() and main(void)? without int
What do argc, and argv have to do with main's return type?
brewbuck is referring to main()'s parameters. I think the OP is referring to both main()'s return type and parameters, but in that case, I think the question was related to the return type being implicitly declared as int.
Mostly out of laziness/ignorance, but that doesn't mean there isn't a valid reason for not using int main(void). For example, programming for embedded systems may often include "non-standard" code, such as void main(void).Quote:
So why do people continue to use main() and main(void)? without int
As for the implicit return of 0, I personally always make use of this unless I intend on returning a specific result. This is beneficial, because in the future, if the standards committee decides that main will now return X by default instead of 0, or will return X and perform some clean-up code, then you no longer have to worry about correcting all the "return 0"'s you hard-coded into your source in the past.
this is highly unlikely due to this functioning in scripts:
it would instantly invalidate every C program and most scripts, making a lot of work for people to recode their programs and scripts, making a lot of programmers and scripters unhappy.Code:app
if(!ret_val) echo error!