- 论坛徽章:
- 0
|
- #include <stdio.h>
- #include <getopt.h>
- #include <stdlib.h>
- const char * program_name;
- void print_usage(FILE *stream, int exit_code)
- {
- fprintf(stream, "Usage: %s option [outputs]\n", program_name );
- exit(exit_code);
- }
- int main(int argc, char const *argv[])
- {
- /* code */
- program_name = argv[0];
- int next_option;
- static struct option const long_option[] =
- {
- {"help", 0, NULL, 'h'},
- {"output", 1, NULL, 'o'},
- {"verbose", 0, NULL, 'v'},
- {NULL, 0, NULL, 0}
- };
- while( (next_option = getopt_long(argc, argv, "ho:v", long_option , NULL)) != -1)
- {
- switch(next_option)
- {
- case 'h':
- print_usage(stdout, 0);
- break;
- case 'o':
- print_usage(stdout, 0);
- break;
- case 'v':
- print_usage(stdout, 0);
- break;
- default:
- print_usage(stdout, 0);
- break;
- }
- }
- return 0;
- }
复制代码 各位帮忙看看,哪里出错了,一直编译不通过! |
|