int main() vs int main(int argc, char *argv[])

Why does the C++ tutorial for this site not mention ANSI C++ standard int main(int argc, char *argv[]) function. Instead it uses int main(void).

What is the difference?

When does it matter which one I use?
Last edited on
the only difference is that the argc,argv version allows you to get the command line arguments
which are stored in argv as an array of argc NUL-terminated strings
so my understanding is these arguments in the main() function are primarily used for compiler portability?

I'm trying to get into the purist mindset, and learn all the intricacies.
Last edited on
For a basic tutorial such as that on this site, then adding in more details that aren't really necessary would just seek to confuse the target audience.

However, when developing more complex applications than "Hello world!" it is often useful to have the program take command-line options, and so this is usually dealt with by a separate, slightly later tutorial.

I think perhaps some modern compilers would flag an unreferenced assignment of argc,argv as a warning, too?
Topic archived. No new replies allowed.