/* * This program prints out all the command line arguments. * If there are no arguments it will echo what you write until * you type CNTR+D. * After David Albrecht, CSSE, Monash University, Australia, 16/2/2001 */ #include main(int argc, char *argv[]) { int c, i; if (argc == 1) /* No command line arguments */ while ((c = getchar()) != EOF) /* echo whatever is typed */ putchar(c); else /* at least one command line argument */ { printf("\n"); for(i = 0; i < argc; i++) printf("argv[%d]=\"%s\"\n", i, argv[i]); /* print each argument */ printf("\n"); /* NB argv[0] = program name */ } }