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.
{
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[]) .