程序清单8-9 回送所有命令行参数和所有环境字符串

 1 /*
 2  ============================================================================
 3  Name        : test.c
 4  Author      : blank
 5  Version     :
 6  Copyright   : Your copyright notice
 7  Description : 程序清单8-9 回送所有命令行参数和所有环境字符串
 8  ============================================================================
 9 */
10 
11 #include "ourhdr.h"
12 
13 int main(int argc, char *argv[])
14 {
15     int     i;
16     char     **ptr;
17     extern char **environ;
18 
19     /*
20      * echo all command-line args
21      */
22     for (i=0; i<argc; i++){
23         printf("argv[%d]: %s\n", i, argv[1]);
24     }
25 
26     /*
27      * and all env strings
28      */
29     for (ptr = environ; *ptr!=0; ptr++){
30         printf("%s\n", *ptr);
31     }
32 
33     exit(0);
34 }

 

posted @ 2014-05-05 22:42  blankqdb  阅读(251)  评论(0编辑  收藏  举报