- 论坛徽章:
- 0
|
int main(int argc,char **argv)
{
int ch;
opterr = 0;
while((ch = getopt(argc,argv,"a:b:c:d:e"))!= -1)
switch(ch)
{
case 'a':
printf("option a:'%s'\n",optarg);
break;
case 'b':
printf("option b :b\n");
break;
default:
printf("other option :%c\n",ch);
}
printf("optopt +%c\n",optopt);
}
while((ch = getopt(argc,argv,"a:bcde"))!= -1)
./test -bc
option b :b
other option :c
optopt +
while((ch = getopt(argc,argv,"a:b:c:d:e"))!= -1)
./test -bc
option b :b
optopt +
-bc这种情况下为什么没有取到c呢?好像应该打印出
./test -bc
option b:'c'
optopt + |
|