/* 目录: 一 两个参数 二 三个参数 */
一 两个参数
// 测试参数 - 前两个 int main(int argc, char *argv[]) { printf("Have %d String ", argc); int nCount = 0; while (NULL != argc) { printf("%s ", argv[nCount]); ++nCount; --argc; } return 0; }
二 三个参数
说明: 第三个参数用来在程序运行时获取系统的环境变量,操作系统运行程序时通过envp 参数将系统环境变量传递给程序
// 测试参数 - 第三个 int main(int argc, char *argv[], char **envp) { int nCount = 0; while (envp[nCount]) { if (envp[nCount]) { printf("envp[%d] is %s. ", nCount, envp[nCount]); } ++nCount; } return 0; }