/* Example taken from http://www.ihypress.net/programming/c/prog.php?chap=12&pgm=01 Using command-line arguments */ #include /* argc: number of arguments (always at least 1) */ /* argv: array of strings containg the arguments */ int main (int argc, char *argv[]) { int i; /* argument 0 identifies the program */ printf ("This program was called with \"%s\".\n",argv[0]); /* arguments from 1 are passed to the program */ /* displays the arguments as entered */ printf ("Arguments passed: "); for (i = 1; i < argc; ++i) printf("%s ", argv[i]); printf ("\n"); /* diaplays each idividual strings of arguments */ if (argc > 1) { for (i = 1; i < argc; ++i) printf("argv[%d] = %s\n", i, argv[i]); } else { printf("The command had no other arguments.\n"); } return (0); }