Reference: syntax: ISO/IEC 14882:2011 C plus plus standard paper 3.6.1 Main function int main(int argc, char* argv[]) { /* ... */ } In the latter form argc shall be the number of arguments passed to the program from the environment in which the program is run. If argc is nonzero these arguments shall be supplied in argv[0] through argv[argc-1] as pointers to the initial characters of null-terminated multibyte strings (NTMBSs) (17.3.2.1.3.2) and argv[0] shall be the pointer to the initial character of a NTMBS that represents the name used to invoke the program or "". The value of argc shall be nonnegative. The value of argv[argc] shall be 0. [Note: it is recommended that any further (optional) parameters be added after argv. ] Reference: Version2: <<C plus plus primer>> author:stanly .B.lippman 7.2.6 main:处理命令行 主函数main是演示c程序如何将数组传递给函数的好例子,直到现在,我们定义的主函数都只有空的形参表: int main() {...} 但是,我们通常需要给main传递实参,传统上,主函数的实参是可选的,用来确定程序要执行的操作,比如,假设我们的主函数main位于名为,prog的可执行文件中,可如下将实参选项传递给程序: prog -d -o -ofile -data0 这种用法的处理方法实际上是在主函数main中定义了两个形参: int main(int argc,char *argv[]){.....}