I need my program to get several arguments from command line, the syntax is as follows:
getpwd -l user1 user2 ... -L -X -S...
So, I need to get
The following function will generate an argc, argv pair for a single option within an argument list:
void GetArgsList (int argc, char *argv[], int* o_argc, char*** o_argv)
{
char** ret = NULL;
int i;
int count = 0;
for (i = optind - 1; i < argc ; ++i)
{
if (argv[i][0]=='-')
{
break;
}
else
{
if (NULL == ret)
{
ret = &argv[i];
}
count++;
}
}
optind = i - 1;
if (o_argc)
{
*o_argc = count;
}
*o_argv = ret;
}