- 论坛徽章:
- 2
|
本帖最后由 leiing 于 2016-08-09 14:43 编辑
看资料getopt只能解析短参数的,如-c -o -E,而getopt_long是解析长参数的,如--help。
但是像-Wall,只有一个横线,但有多个字符,如何解析?
- int opt = 0;
- static const char *optString = "Il:o:vh?";
- opt = getopt( argc, argv, optString );
- while( opt != -1 ) {
- switch( opt ) {
- case 'I':
- break;
-
- case 'l':
- break;
-
- case 'o':
- break;
-
- case 'v':
- break;
-
- case 'h': /* fall-through is intentional */
- case '?':
- display_usage();
- break;
-
- default:
- /* You won't actually get here. */
- break;
- }
-
- opt = getopt( argc, argv, optString );
- }
-
复制代码 谢谢。
|
|