The arguments are passed to your C++ application (no matter if it is a console application or not; it also could be the windowed UI application, or the application with no screen input/output at all) through its
entry point.
Please see:
http://en.wikipedia.org/wiki/Main_function#C_and_C.2B.2B[
^].
With C++, to allow for passing command line to your code, you need to use the entry-point function with one of the following signatures:
int main(int argc, char **argv);
int main(int argc, char *argv[]);
int main(int argc, char **argv, char **envp);
int main(int argc, char **argv, char **envp, char **apple);
The actual values for the function arguments
argc
and
argv
will be taken from the command line actually entered by the customers (directly for from script, Shell, Windows *.lnk file, etc.) by the system loaded and passed to your entry-point function. You application code should use them; parse the command line parameters to figure out the options.
Note: The "entry-point" function supplied by your application code can have different name and even somewhat different signature. It might happen when you are using certain framework defines
main
internally and calls some other function (such as
_tmain(int argc, _TCHAR* argv[])
where you can use different character types, depending on compilation option) which your application should supply. The idea is the same or very close, anyway.
—SA