Each C language program must have a function called main () as the starting point for the program to start. When executing a program, command-line arguments (command-line argument) (parsed by the shell) are supplied to the main () function by two arguments. The first argument, int argc, represents the number of command-line arguments. The second argument, Char *argv[], is an array of pointers to command-line arguments, each of which is a string that ends with a null character (null). The first string, that is, argv[0] points to, (usually) the name of the program. The list of pointers in argv ends with a null pointer (that is, ARGV[ARGC] is null).
Argv[0] contains the name of the calling program,
Using main (int argc,char *argv[]) = = Main (int argc,char **argv) Basic operation is the most basic step of Linux programming, under Windows is also exe out of the IDE to run the necessary skills, after the program was compiled successfully, Under CMD, use the parameter input to run the program and control the input of the parameters to test and run the program.
int ARGC represents the number of input parameters, the English full name argumentscount, is counted as a space, and the program name (*.exe) is the first parameter.
Char *argv[] Stores the contents of the parameter as an array of characters, the English full name arguments vector, argv[1] represents the program name.
The following program shows the use of ARGC and argv:
#include <stdio.h>int main (int argc, char * * argv) { int i; for (i=0; i < argc; i++) printf ("Argument%d is%s./n", I, Argv[i]); return 0;}
If the above code is compiled to Hello.exe, then run
Hello.exe a b c d E
Will get
Argument 0 is hello.exe.Argument 1 are a.argument 2 is b.argument 3 are c.argument 4 is d.argument 5 is E.
Run
Hello.exe lena.jpg
Will get
Argument 0 is hello.exe.Argument 1 is lena.jpg.
Method 2. Project--Properties--Configuration Properties--debug--command parameters, set command parameters can be passed in
Http://www.cnblogs.com/rainbow70626/p/5595454.html
Main (argc,argv[])