linux c main function parameters

linux c main function parameters

http://www.cnblogs.com/RascallySnake/archive/2012/01/05/2313352.html

The main function has two parameters

main(int argc,char *argv[])

The first is the number of integers representing the entire parameter;

The second is a character array, argv[0] refers to the instruction, that is, the file name of the general c program (in the Linux environment, it is the compiled executable file name), argv[1], argv[2].. ..... are the corresponding parameters.

For example: I have compiled a program to copy the program of file1 to file2, and the executable file after my C language code is compiled is called copy

So when I use it, my format is: copy file1 file2;

Among them, argv[0] is copy; argv[1] refers to file1; argv[2] refers to file2.

Guess you like

Origin blog.csdn.net/lgdlchshg/article/details/41007807