
// illustration of use of command-line arguments 

// main() has two arguments dealing with the command line, which we
// usually name argc and argv; the latter is an array of strings, i.e.
// of type char *[], or more succinctly, char **; argc is then the count
// of the number of command-line arguments

// suppose there are two command-line arguments, one a string and the
// other an integer, so that for example the program command line might
// look like

//    % a.out abc 12

// then argv[1] would be "abc" and argv[2] would be "12"

// argv[0] is the program name, in this case a.out

main(int argc, char **argv)

{  char *s; 
   int x;

   strcpy(s,argv[1]);

   // OK, we've got the first string, but the second is intended to be an
   // integer, so we must convert it; the usual way to do this is the
   // atoi() function ("ASCII to integer") from the C library; it
   // converts a string to an integer

   x = atoi(argv[2]);
   ...  // and then do whatever with s and x
}


