【发布时间】:2014-05-25 03:34:56
【问题描述】:
你知道 getopt() 函数。我用它成功地获得了两个选项,但我不知道如何获得三个选项。我该怎么做?
这是我如何获得其中两个:
while ((c = getopt(argc, argv, "al?:")) != -1){
switch(c){
case 'a' :
hide_hidden_files = false;
break;
case 'l' :
show_file_info = true;
break;
case '?' :
//error handling here
return 1;
}
}
【问题讨论】:
-
通过添加另一个选项和另一个开关盒。
-
没想到答案这么简单。谢谢你:)
-
下次先读the documentation。
-
@OliCharlesworth:为什么不将其添加为 aswer,这样可以“关闭”?
标签: c command-line command-line-arguments getopt