Alcott
Alcott

Reputation: 18585

use getopt to obtain multiple options

Here is my problem, I wrote a program a.exe, it can take several options, like "r:e:m:". r: and m: can't appear together, which means they run totally different tasks inside a.exe. And e: is an optional option, if it shows up, then it should be with r:.

How should I implement this logic with getopt?

Upvotes: 1

Views: 163

Answers (1)

Some programmer dude
Some programmer dude

Reputation: 409166

You have to manually check for incompatible options. For example, when you see the -r option you set a flag saying "-r is found", if you then see the -m option you check to see if the "-r is found" flag is set, and print an error message telling the user about it.

Upvotes: 1

Related Questions