if Our program is written like this int main (int argc,char *argv[]) { cout<<argv[1]<<endl; return 0; } run a.out command line ./a.out string Here string is what you want to print if rewriting cout<<argv[0]<<endl; then Print ./a.out cout<<argv[2]<<endl; so nothing of course you can type in this ./a.out 123 456 789 will print 456 variable parameter list is actually doing a predefined area dividing an area first to install the upcoming parameters of course the same type of #include <iostream>using namespace std;int m (int argc,char *argv[]) { cout <<&argv[0]<< ":" <<ARGV[0]<<ENDL;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;COUT<<&ARGV [1]<< ":" <<argv[1]<<endl; cout<<&argv[2]<< ":" <<argv[2]<<endl; cout<<&argv[3]<< ":" <<argv[3]<<endl; cout<<&argv[4]<< ":" <<argv[4]<<endl; return 0; } int main (int argc,char *argv[])// Exchange parameter Order warning and cannot run { m (ARGC,ARGV); return 0; } [[email protected] ~]$ ./a.out can be used in addition to the main function common functions 111 222 333 444 555 666 7770xbfe7ca54:./a.out0xbfe7ca58:1110xbfe7ca5c : 2220xbfe7ca60:3330xbfe7ca64:444 can see the string in the back of the first stack high address C program stack at the bottom of the high address, the top of the stack is low address, So the above example can show that the function parameter in the stack order is really right-to-left variadic function can be implemented by function overloading 666 article http://www.cnblogs.com/ dongsheng/p/4001555.html But the test is not perfect &Nbsp; inside the function vsprintf () compiler different will not be #include <stdio.h> #include <stdarg.h> int mysum (int n, ...) { // (1) Define a parameter list va_list ap; // (2) Initialize parameter list va_start (ap, n); int result = n; int temp = 0; // Getting parameter values while ((Temp = va_arg (ap, int)) != end) { result += temp; } // Close the parameter list va_end (AP); return Result;} int main () { int m = mysum (1, 2, 3, 4, 5, end); printf ("%d", m); &NBSP;&NBSP;&NBSP;&NBSP;RETURN&Nbsp;0;} Use macro definitions to handle the problem of total need to end the symbol otherwise int m = mysum (1, 2, 3, 4, 5, -1,-1), so write won't add -1 that value.
Re-review of variable parameters