I have been trying a number of ways to copy char *argv[].
I need to parse the command line and call different functions with a subset of the main argument list.
Code:
/* the objective is to copy argv into another array */
/* eventually, for example, copy the 3rd, 4th, 5th argv into 1st, 2nd 3rd arguments */
int main (int argc, char *argv[])
{
int j;
char * arguments[30]; /* max argument size */
for (j = 1; j < argc; j++)
{
strcpy (arguments[j], argv[j]); /* compiles, but get an unhandled exception here */
}
}
Code:
int main (int argc, char *argv[])
{
int j;
char ** arguments;
for (j = 1; j < argc; j++)
{
strcpy (arguments[j], argv[j]); /* Run-Time Check Failure #3 - The variable 'arguments' is being used without being initialized. */
}
}
Any direction you can provide is much appreciated.
Thanks,
-dog