【发布时间】:2014-08-14 03:32:29
【问题描述】:
我已尝试搜索,但没有找到重复/类似的问题。
为什么在这种情况下“默认”永远不会触发?为秋季准备的课程做一些以前的家庭作业,我遇到了 C 语言中的 getopt() 问题。
以下是有问题的特定行:
while ((c = getopt(argc, argv, "i:o:")) != -1) {
switch (c) {
case 'i':
inFile = strdup(optarg);
break;
case 'o':
outFile = strdup(optarg);
break;
default:
usage(); //this prints the "usage" statement and exits cleanly.
}
}
我的问题是,怎么来电话
./fastsort a b c d
不打印使用情况并退出?
【问题讨论】:
标签: c command-line-arguments getopt