LoveUnix » 编程开发 & Rational » 怎么让getopt_long打印错误信息?
让LU留住您的每

一天 让LU博客留住您的每一天
2005-11-10 18:07 bird_in_net
怎么让getopt_long打印错误信息?

while (1) {
               int this_option_optind = optind ? optind : 1;
               int option_index = 0;
               static struct option long_options[] = {
                   {"add", 1, 0, 0},
                   {"append", 0, 0, 0},
                   {"delete", 1, 0, 0},
                   {"verbose", 0, 0, 0},
                   {"create", 1, 0, 鈉鈣,
                   {"file", 1, 0, 0},
                   {0, 0, 0, 0}
               };

               c = getopt_long (argc, argv, "abc:d:012",
                        long_options, &option_index);
        if (c == -1)
                   break;

switch (c) {
               case 0:
                   printf ("option %s", long_options[option_index].name);
                   if (optarg)
                       printf (" with arg %s", optarg);
                   printf ("\n");
                   break;

               case 'a'
               case 'b'
                   break;
               case '?'
                 return 0;

               default:
                   abort();
                    return 0;
}}}

为什么我输入 文件名 -a给程序.这个非法,什么都不打印?

哪位大侠帮帮忙?
先谢了

页: [1]


Powered by Discuz! Archiver 5.5.0  © 2001-2006 Comsenz Inc.