如何指定短选项可以接受 getopt
中的可选参数。
据我所知,GNU 的 C 语言 getopt 库仅通过在给定选项后添加 :
来支持短选项的必需参数。
示例:
static const char* short_opts = "s:evlh";
如何指定 s
接受参数,但不需要它们?
我知道如何在 Ruby 中执行此操作,但我一直无法弄清楚如何在 C 中执行此操作 - 我已经多次查看了 getopt 的 GNU 文档,但无济于事。
最佳答案
来自documentation :
If an option character is followed by two colons (‘::’), its argument is optional; this is a GNU extension.
关于c - 指定给定的 Shortopt 可以接受可选参数 C,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17933286/