Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用函数getopt_long来获取命令行选项。当给出无效选项时,我想忽略错误。目前它向标准错误打印错误,例如:
getopt_long
invalid option -- 's'
getopt.h 中有一个变量, 如果您将其设置为 0 opterr,它将避免打印错误。stderr
opterr
stderr
只需将其设置为 0:
extern int opterr; opterr = 0;