命令行参数可以分为两类,一类是短选项,一类是长选项,短选项在参数前加一杠"-",长选项在参数前连续加两杠"--"。如:-a,-A,-b都表示短选项;--all,--almost-all,--author都表示长选项。
getopt
短选项的解析
getopt_long
getopt_long函数的工作原理与getopt类似,只是它也接受以两个短划线开头的长选项。
getopt_long_only
getopt_long_only类似于getopt_long,但是'-'和"--"都可以表示长选项。如果以'-'(不是"--")开头的选项不匹配长选项,但匹配短选项,则将其解析为短选项。
ChatGPT
getopt, getopt_long, and getopt_long_only are functions used in C and C++ programming for parsing command-line arguments. They help in handling options passed to t
订阅专栏 解锁全文
137




被折叠的 条评论
为什么被折叠?



