Command line arguments are available by adding two parameters.
Run Programme: ./prog -a -b -cde
This passes four arguments to the programme:
This data is available within main() as the second input parameter (by convention, argv). The first input parameter to main holds the number of passed arguments (in this case, four) and by convention is called argc.
The argv parameter is a C-style array of primitive strings (char * objects)- and may be represented as char * argv or char ** argv.
Note that main(argc, char ** argv) and main(argc, char * argv) are equivalent:
char ** argv: declare argv as pointer to pointer to char (A pointer to char *)
char * argv: declare argv as array of pointer to char (A primitive array of char * objects)
They are equivalent because a pointer to char * is the same as an array of char *.
In the current example, argc is 4 and the four elements of argv are pointers to the arrays of characters passed in as arguments.