4 ms·
Besides, int main(void) is shorter to type. And, horridly, return isn't necessary in main, so you don't even have to be bothered to type that. int main(void)-
by beej71 16y ago
Besides, int main(void) is shorter to type. And, horridly, return isn't necessary in main, so you don't even have to be bothered to type that.
int main(void)--for the lazy AND correct!
- wnoise 16y ago> And, horridly, return isn't necessary in main, Only true for C++.
- hoop 16y agobut it works for me!
- henning 16y agoWorks On My Machine(tm) http://www.codinghorror.com/blog/2007/03/the-works-on-my-machine-certification-program.html http://www.codinghorror.com/blog/2007/03/the-works-on-my-mac...
- beej71 16y agoAlso true in C99 5.1.2.2.3: "reaching the } that terminates the main function returns a value of 0."
- ssp 16y agoFor the even lazier: main(void) Though I vaguely recall something about this being deprecated in C99.
- JoachimSchipper 16y agoYes, that's deprecated. And it was horrible before.
- zokier 16y agoWouldn't int main() be even better. Shorter, and acknowledges that main actually takes parameters (command line arguments).
- hackermom 16y agoGCC (as an example) turns () and ( void ) into the exact same output. I have some memory of long, long ago entering the world of C in the hands of the DICE compiler for the Amiga, that being clear in the declaration of functions is The Right Way: say void, or say inputs. Semantically I consider ( void ) to simply say "in this case, we're not going to be using any input vectors", rather than "this function can never have inputs; it's not supported". Clarity is never wrong.
- zokier 16y agomain is a special case, but generally () and (void) are different, void meaning that the function cannot have any parameters and empty allowing any number of arguments. Therefore imho is clearer to use main() rather than main(void), indicating that there may be parameters, but we don't care. http://codepad.org/UGLG7yRm http://codepad.org/UGLG7yRm and http://codepad.org/w2GyTkB1 http://codepad.org/w2GyTkB1