gpt4 book ai didi

c - 指定给定的 Shortopt 可以接受可选参数 C

转载 作者:行者123 更新时间:2023-11-30 15:46:51 24 4
gpt4 key购买 nike

如何指定短选项可以接受 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com