getopt usage with/without option
问题 I'm writing a simple code making use of *argv[] parameter. I'd like to know whether I can use getopt() function for the following intent. ./myprogram -a PATH ./myprogram PATH The program can either take merely PATH (e.g. /usr/tmp ) or take -a option in addition to PATH . Can getopt() be used for this state? If can, how? 回答1: The program can either take merely PATH (e.g. /usr/tmp ) or take option in addition to PATH . Can getopt() be used for this state? If can, how? Certainly. I'm not sure