【发布时间】:2018-01-03 17:16:00
【问题描述】:
static struct option long_options[] =
{
{"r", required_argument, 0, 'r'},
{"help", no_argument, 0, 'h'},
{0, 0, 0, 0}
};
int option_index = 0;
char c;
while((c = getopt_long(argc, argv, "r:h", long_options, &option_index)) != -1)
{
switch(c)
{
case 'r':
break;
case 'h':
return EXIT_SUCCESS;
}
}
如何让 h 成为默认参数,所以如果这个程序在没有任何参数的情况下运行,就好像它是用 -h 运行的一样?
【问题讨论】:
标签: c++ arguments command-line-arguments getopt getopt-long