As per the current standard and cppreference these two are the correct way to define the main()
function. I know what the parameters mean in either definition, and am not seeking clarifications on that aspect. What I'd like to understand is:
- When to use
int main (void)
v/sint main (int argc, char *argv[])
. - Hypothetically, when the program doesn't expect command-line arguments, is there any difference to the compiler (let's say
gcc
andclang
) at all? - (Just for the sake of writing self-documenting code) should I use
int main (void)
when the program doesn't expect command line arguments andint main (int argc, char *argv[])
when it does?