C getopt multiple value

前端 未结 5 893
隐瞒了意图╮
隐瞒了意图╮ 2020-11-29 05:24

My argument is like this

./a.out -i file1 file2 file3

How can I utilize getopt() to get 3 (or more) input files? I\'m doing s

5条回答
  •  旧巷少年郎
    2020-11-29 06:07

    Note that glibc's nonconformant argument permutation extension will break any attempt to use multiple arguments to -i in this manner. And on non-GNU systems, the "second argument to -i" will be interpreted as the first non-option argument, halting any further option parsing. With these issues in mind, I would drop getopt and write your own command line parser if you want to use this syntax, since it's not a syntax supported by getopt.

提交回复
热议问题