getopt help required

R

Rishi

suppose i have a program in which there are two arguements 'a' and 'b'

the program is such that i will work iff
-> either 'a' or 'b' is present as an option to it
-> both 'a' and 'b' cant be present sameltaneously
-> either of the two should be there

I want to know is there any way in the function getopt or getopt_long
that can help me in doing this


Thanks in advance
 
D

Daniel Kraft

Rishi said:
suppose i have a program in which there are two arguements 'a' and 'b'

the program is such that i will work iff
-> either 'a' or 'b' is present as an option to it
-> both 'a' and 'b' cant be present sameltaneously
-> either of the two should be there

I want to know is there any way in the function getopt or getopt_long
that can help me in doing this

Well, I'm not sure this is on topic here (comp.unix.programmer might be
better), but AFAIK getopt can set a boolean flag on encountering an
option; just do this, and check afterwards your conditions against the
two flag-variables and take appropriate action.

Daniel
 
K

Kenny McCormack

suppose i have a program in which there are two arguements 'a' and 'b'

the program is such that i will work iff
-> either 'a' or 'b' is present as an option to it
-> both 'a' and 'b' cant be present sameltaneously
-> either of the two should be there

I want to know is there any way in the function getopt or getopt_long
that can help me in doing this


Thanks in advance

Off topic. Not portable. Cant discuss it here. Blah, blah, blah.

--
Useful clc-related links:

http://en.wikipedia.org/wiki/Aspergers
http://en.wikipedia.org/wiki/Clique
http://en.wikipedia.org/wiki/C_programming_language
 
M

Malcolm McLean

Rishi said:
suppose i have a program in which there are two arguements 'a' and 'b'

the program is such that i will work iff
-> either 'a' or 'b' is present as an option to it
-> both 'a' and 'b' cant be present sameltaneously
-> either of the two should be there

I want to know is there any way in the function getopt or getopt_long
that can help me in doing this
I've got an options parser on my website that may do what you want.
 
M

Mark Bluemel

Rishi said:
suppose i have a program in which there are two arguements 'a' and 'b'

the program is such that i will work iff
-> either 'a' or 'b' is present as an option to it
-> both 'a' and 'b' cant be present sameltaneously
-> either of the two should be there

I want to know is there any way in the function getopt or getopt_long
that can help me in doing this

getopt is not part of the language, it's a Posix library function, so
it's not really on-topic here.


Depending on whether you really want the Posix version or the GNU
variant, you'd need to look in slightly different places.

As far as I can see from a brief examination, neither provide an easy
way of making options/arguments mutually exclusive.
 
K

Keith Thompson

Rishi said:
suppose i have a program in which there are two arguements 'a' and 'b'

the program is such that i will work iff
-> either 'a' or 'b' is present as an option to it
-> both 'a' and 'b' cant be present sameltaneously
-> either of the two should be there

I want to know is there any way in the function getopt or getopt_long
that can help me in doing this

Ask in comp.unix.programmer.
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top