Up to now, we have been using the first form of main():
int main( void ) { ... }
The second form of main() is as follows:
int main( int argc , char* argv[] ) { ... }
Here, we have the following:
- argc is the short name for the argument count.
- argv is the short name for the argument vector.
When our program declares the main() function in the second form, the command-line interpreter processes the command line and populates these two variables, passing them into the main() function body when the system calls main(). We can then access those values through these variable names.
It should be noted that argc and argv are arbitrary names. You might want to use alternative names in main(), as follows:
int main( int argumentCount, char* argumentVector[] ) { ... }
You could even use the following:
int main( int numArgs, char* argStrings[] ) { ... }...