如何使用C ++ getopt_long()如果我有超过26个选项? [英] How to use C++ getopt_long() if I have more than 26 options?

查看:296
本文介绍了如何使用C ++ getopt_long()如果我有超过26个选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个相当假设的问题,但让我们说,我有3个长参数以相同的字母开头。

This is a rather hypothetical question, but let's say I have 3 long parameters that begin with the same letter.

--parse or -p
--prune or -r
--pivot or -i

最后,我将开始使用单个字母,有意义,有意义的在 GNU getopt_long()配置。

Eventually I'll start running out of single letters that make sense, more over, it's hard assign something meaningful in GNU getopt_long() configuration.

{"parase", no_argument,       0, 'p'},
{"prune",  no_argument,       0, 'r'},
{"pivot",  required_argument, 0, 'i'}


b $ b

这些情况下的最佳做法是什么?

What is the best practice in these situations?

推荐答案

您可以选择大写,小写,给你52个短选项,然而许多程序接受长选项甚至不麻烦给一些选项分配短选项,迫使用户只使用长选项,这确定。

You have a choice of uppercase, as well as lowercase, giving you 52 short options, however many programs that accept long options don't even bother assigning short options to some options, forcing the user to use the long options only, which OK.

这篇关于如何使用C ++ getopt_long()如果我有超过26个选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆