os161-1.99
 All Data Structures
argtest.c
00001 /*
00002  * Program to test argument passing: it displays the argc and all
00003  * of argv, and then exits.
00004  *
00005  * Intended for the basic system calls assignment. This may help
00006  * debugging the argument handling of execv().
00007  */
00008 
00009 #include <stdio.h>
00010 
00011 int
00012 main(int argc, char *argv[])
00013 {
00014         const char *tmp;
00015         int i;
00016 
00017         printf("argc   : %d\n", argc);
00018         printf("&tmp   : %p\n", &tmp);
00019         printf("&i     : %p\n", &i);
00020         printf("&argc  : %p\n", &argc);
00021         printf("&argv  : %p\n", &argv);
00022         printf("argv   : %p\n", argv);
00023         printf("\n");
00024 
00025         for (i=0; i<=argc; i++) {
00026                 printf("&argv[%d] : %p\n", i, &argv[i]);
00027         }
00028         printf("\n");
00029 
00030         for (i=0; i<=argc; i++) {
00031                 printf("argv[%d] : %p\n", i, argv[i]);
00032         }
00033         printf("\n");
00034 
00035         for (i=0; i<=argc; i++) {
00036                 tmp = argv[i];
00037                 if (tmp == NULL) {
00038                         tmp = "[NULL]";
00039                 }
00040                 printf("argv[%d] -> %s\n", i, tmp);
00041         }
00042 
00043         return 0;
00044 }
 All Data Structures