谁能帮我看一下这个关于getopt()函数的程序啊~
来源: 互联网 发布时间:2014-12-28
本文导语: #include #include #include int main(int argc,char* argv[]) { int opt; while ((opt=getopt(argc,argv,"if:lr")) != -1) { switch (opt) { case 'i': case 'l': case 'r': printf("option: %cn",opt); break; case 'f': printf("filename: %sn",opt...
#include
#include
#include
int main(int argc,char* argv[])
{
int opt;
while ((opt=getopt(argc,argv,"if:lr")) != -1)
{
switch (opt)
{
case 'i':
case 'l':
case 'r':
printf("option: %cn",opt);
break;
case 'f':
printf("filename: %sn",optarg);
break;
case ':':
printf("option needs a valuen");
break;
case '?':
printf("unknown option: %cn",optopt);
break;
}
}
for (;optind
#include
#include
int main(int argc,char* argv[])
{
int opt;
while ((opt=getopt(argc,argv,"if:lr")) != -1)
{
switch (opt)
{
case 'i':
case 'l':
case 'r':
printf("option: %cn",opt);
break;
case 'f':
printf("filename: %sn",optarg);
break;
case ':':
printf("option needs a valuen");
break;
case '?':
printf("unknown option: %cn",optopt);
break;
}
}
for (;optind