You seem to have a very wrong concept of what exactly argc is.
To pass arguments to a program a user does this: program argument1 argument2 ...
The shell will interpret the command line however it wants and create an array out of that. Assuming program is found, this array will eventually get passed to its main().
The shell will pass at least two things to the program: the command that called the program, and a string with all the arguments. Some shells (Bash) will parse the arguments and pass them directly to the program, while others (Windows) will simply pass the argument string unprocessed and leave interpretation up to the program (in console programs, this happens before main() is called, so don't worry about it). Regardless, you can't restrict how many arguments are passed, except by quitting when the wrong number of arguments is found.
main is an unusual function.
It is called by the operating system, and as C++ can run on many systems and the C++ standards cannot dictate to OS writers what data they pass to programs running on that OS - you
can write any parameters you like in the main functions and the compiler will accept it.
The following is meaningless but will compile with no problem:
1 2 3 4
int main(char* pc, float g)
IIRC, the C++ standards only stipulate the following concerning parameters to and from main
1. main must return int
2. The follwing prototypes must be honoured by the compiler
int main(int, char *)
int main (intchar**)
3. if there is no explicit return statement - then 0 is automatically returned.
Yes... I was wondering if jsmith would pop up with a link like this... But it was you instead... Anyway, I just wanted to demonstrate a simple implementation for handling switches. I don't doubt that boost does it in a more elegant way (and neither do I doubt that I could do it too if I spent more time on it).