B
Billy Patton
I need to parse argv to remove known arguments from the array.
But I want it to leave the rest intact. I need to pass these through to other
system calls.
I've found references to several libraries but have been unable to get any to
compile.
What I would like is somethhing like:
$prog -a 1 -b 2 -c 3
INside program:
int main(int argc,char** argv)
{
do_args(argc,argv);
argv now is -c 3 because I knew about and wanted -a and -b
}
do_args(int& argc,char**& argv)
{
switch ()
{
case '-a': reduce from argv and argc
case '-b':
default :
if (pass_thru == 0)
{
print gotta argument we don't know about
}
else
{
print argument '%s' not accounted for passing thru\n"
}
}
perl does this in GetOpt::Long
___ _ ____ ___ __ __
/ _ )(_) / /_ __ / _ \___ _/ /_/ /____ ___
/ _ / / / / // / / ___/ _ `/ __/ __/ _ \/ _ \
/____/_/_/_/\_, / /_/ \_,_/\__/\__/\___/_//_/
/___/
Texas Instruments ASIC Circuit Design Methodology Group
Dallas, Texas, 214-480-4455, (e-mail address removed)
But I want it to leave the rest intact. I need to pass these through to other
system calls.
I've found references to several libraries but have been unable to get any to
compile.
What I would like is somethhing like:
$prog -a 1 -b 2 -c 3
INside program:
int main(int argc,char** argv)
{
do_args(argc,argv);
argv now is -c 3 because I knew about and wanted -a and -b
}
do_args(int& argc,char**& argv)
{
switch ()
{
case '-a': reduce from argv and argc
case '-b':
default :
if (pass_thru == 0)
{
print gotta argument we don't know about
}
else
{
print argument '%s' not accounted for passing thru\n"
}
}
perl does this in GetOpt::Long
___ _ ____ ___ __ __
/ _ )(_) / /_ __ / _ \___ _/ /_/ /____ ___
/ _ / / / / // / / ___/ _ `/ __/ __/ _ \/ _ \
/____/_/_/_/\_, / /_/ \_,_/\__/\__/\___/_//_/
/___/
Texas Instruments ASIC Circuit Design Methodology Group
Dallas, Texas, 214-480-4455, (e-mail address removed)