What's an effective way to parse command line parameters in C++?

前端 未结 6 2048
滥情空心
滥情空心 2021-02-09 05:46

Is there a really effective way of dealing with command line parameters in C++?

What I\'m doing below feels completely amateurish, and I can\'t imagine this is how comma

6条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-09 06:36

    You probably want to use an external library for that. There are many to chose from.

    Boost has a very feature-rich (as usual) library Boost Program Options.

    My personal favorite for the last few years has been TCLAP -- purely templated, hence no library or linking, automated '--help' generation and other goodies. See the simplest example from the docs.

提交回复
热议问题