#include<stdio.h>
#include<unistd.h>
extern char *optarg;
extern int optind, optopt,opterr;
int main(int argc,char **argv)
{
int ch;
while((ch = getopt(argc,argv,"a:bcd")) != -1)
switch(ch)
{
case 'a':
printf("option a:'%s'
",optarg);
break;
case 'b':
printf("option b :b
");
break;
case '?':
case 'h':
printf("usage
");
break;
default:
printf("other option :%c
",ch);
}
if (1 == argc)
printf("usage
");
printf("optopt +%c
",optopt);
}