#include
#include
int main(int argc, char *argv[])
{
int ch, aflag = 0, lflag = 0, i;
while ((ch = getopt(argc, argv, "al")) != -1)
{
switch ( ch )
{
case 'a':
printf("set option -a\n");
aflag = 1;
break;
case 'l':
printf("set option -l\n");
lflag = 1;
break;
default:
printf("wrong option %c\n", ch);
}
}
for (i=optind; i {
printf("%s ", argv[i]);
}
printf("\n");
printf("optind = %d\n", optind);
return 0;
}
阅读(900) | 评论(0) | 转发(1) |