1

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?

4

1 回答 1

1

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.

于 2012-10-31T10:25:09.843 回答