C getopt multiple value

前端 未结 5 889
隐瞒了意图╮
隐瞒了意图╮ 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:13

    The solution by GoTTimw has proven very useful to me. However, I would like to mention one more idea, that has not been suggested here yet.

    Pass arguments as one string in this way.

    ./a.out -i "file1 file2 file3"
    

    Then you get one string as a single argument and you only need to split it by space.

提交回复
热议问题