using getopt() more than once

P

Praveen

Hi,

Any one ever used getopt function more than once. Here is my example.
I have to run a process as

myProcess -x -y -c "-a -f myFile -o myOutput -d debugFile"

First I have to check for -c option and use the value of this -x
argument for next get opt.

Any one has an experience in the same. The reply will be highly
appreciated.

Regards
Praveen Kumar M
 
M

Malcolm

Praveen said:
Any one ever used getopt function more than once. Here is my example.
I have to run a process as

myProcess -x -y -c "-a -f myFile -o myOutput -d debugFile"
The thing to do in these situations is first, read the documentation for the
function, and second do a bit of exploratory programming. Just get the
options and echo them to stdout.
getopt() is not an ANSI function and it is years since I last used it, so I
couldn't tell you exactly how it works.
 
G

Giovanni

Praveen said:
Hi,

Any one ever used getopt function more than once. Here is my example.
I have to run a process as

myProcess -x -y -c "-a -f myFile -o myOutput -d debugFile"

First I have to check for -c option and use the value of this -x
argument for next get opt.

Any one has an experience in the same. The reply will be highly
appreciated.

Regards
Praveen Kumar M

I don't really understand what you mean. But in the manner you wrote it
and assuming that -c is specified with an argument ("c:" in the option
string) the string "-a -f myFile -o myOutput -d debugFile" is parsed as
a single argument to -c. Otherwise will be parsed as a positional argument.

I don't think you can parse it using getopt() since it is a single
string not an array of pointers to the single word.

Ciao
Giovanni
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top