第 11 章 字符串和字符串函数(命令行参数)
程序员文章站
2022-03-17 09:49:25
1 /* 2 repeat.c -- 带参数的 main() 3 */ 4 5 #include 6 7 int main(int argc, char *argv[]) 8 { 9 printf("The command line has %d arguments:\n", a ......
1 /*--------------------------------------- 2 repeat.c -- 带参数的 main() 3 ---------------------------------------*/ 4 5 #include <stdio.h> 6 7 int main(int argc, char *argv[]) 8 { 9 printf("The command line has %d arguments:\n", argc - 1); 10 11 for (int count = 1; count != argc; ++count) 12 printf("%d: %s\n", count, argv[count]); 13 14 printf("\n"); 15 16 return 0; 17 }