would myProgram also be included? It was my impression that, since myProgram was the .exe, using myProgram would instruct the program to run, and everything after it would be the arguments.
If program MyProg.exe is started at the Command Prompt
c:> MyProg file_1 file_2 -lower
the parameters to main()
-
int main(int argc, char *argv[])
-
are :
argc an int which contains the number of command line parameters;
*argv[] is an array of pointers to char (character strings which contain the parameters).
In the command line "MyProg file_1 file_2 -lower" the value of argc would be 4 and argv would appear as follows:
-
element contents contents
-
n of argv[n] of *argv[n]
-
+--------------+ +--------+
-
argv[0] ¦ pointer to _ +---------¦"MyProg"¦
-
¦ ¦ +--------+
-
+--------------¦
-
¦ ¦ +--------+
-
argv[1] ¦ pointer to _ +---------¦"file_1"¦
-
¦ ¦ +--------+
-
+--------------¦
-
¦ ¦ +--------+
-
argv[2] ¦ pointer to _ +---------¦"file_2"¦
-
¦ ¦ +--------+
-
+--------------¦
-
¦ ¦ +--------+
-
argv[3] ¦ pointer to _ +---------¦"-lower"¦
-
¦ ¦ +--------+
-
+--------------¦
-
¦ ¦
-
argv[4] ¦ NULL ¦
-
+--------------+
-
Therefore the elements of argv are pointers to strings which contain the command line parameters (null terminated). By convention argv[0] points to a string which contains the name by which the program was invoked and element argv[argc] is the NULL pointer.