Possible Duplicate:
What parameter parser libraries are there for C++?
What is the best way of parsing command-line arguments in C++ if the program is specified to be run like this:
prog [-abc] [input [output]]
Is there a library in STL to do this?
Related:
Quite a late answer, but I have used GetPot for some projects: http://getpot.sourceforge.net/
Main feature: everything is in a single header file, no build hassles. Just save it somewhere on your machine and "#include" it in your file holding
main()
Hasn't be updated recently, but nicely documentated, and works well. You can give it a try.
I can suggest Templatized C++ Command Line Parser Library (some forks on GitHub are available), the API is very straightforward and (cited from the site):
This is an example from the manual, colored here for simplicity:
I'd recommend boost::program_options if you can use the Boost lib.
There's nothing specific in STL nor in the regular C++/C runtime libs.
AnyOption is a C++ class for easy parsing of complex commandline options. It also parses options from a rsourcefile in option value pair format.
AnyOption implements the traditional POSIX style character options ( -n ) as well as the newer GNU style long options ( --name ). Or you can use a simpler long option version ( -name ) by asking to ignore the POSIX style options.