一:
#include <stdio.h> int main(int argc, const char *argv[]) { int i; for (i = 0; i < argc; ++i) { printf("argv[%d] = %s ", i, argv[i]); } return 0; }
二:
#include <stdio.h> int main(int argc, const char *argv[]) { int i; for (i = 0; i < argc; ++i) { printf("argv[%d] = %s ", i, *(argv + i)); } return 0; }
三:
#include <stdio.h> int main(int argc, const char *argv[]) { int i; for (i = 0; i < argc; ++i, argv++) { printf("argv[%d] = %s ", i, *(argv)); } return 0; }
四:
#include <stdio.h> int main(int argc, const char *argv[]) { int i; for (i = 0; i < argc; ++i) { printf("argv[%d] = %s ", i, *(argv)); argv++; } return 0; }
五:
#include <stdio.h> int main(int argc, const char *argv[]) { const char **p = argv; //用p来代替argv,这里的const不能丢掉 int i; for (i = 0; i < argc; ++i) { printf("argv[%d] = %s ", i, *(p + i)); } return 0; }