Accessing Command-line Arguments from Models


How do you access the command-line arguments from the sim.exe command-line, from within a model?

There is a global data structure defined:

         struct argtype
          {
           int argc;
           char **argv;
          };
And there is a global variable: globargs
         struct argtype  *globargs;
... Which points to the args.
You can access them from within a model as, for example:
        {
         int argc;      /* To hold the number of args. */
         char **argv;   /* To hold the array of argument strings. */

         argc = globargs->argc;
         argv = globargs->argv;

         j = 1;
	 while (j < argc)
	  {
	    printf(" arg%d = /%s/\n", j, argv[j] );
	    j = j + 1;
	  }
        }
This is consistent with the method decribed in K&R (pg. 114, Kernighan-Ritchie) as with main(int argc, char *argv[]) .