There is this post for .Net, but it is not really informative. Any other suggestions? This must be a duplicate, though my first cursory search only turned up the one I already mentioned.
Duplicate of:
There is this post for .Net, but it is not really informative. Any other suggestions? This must be a duplicate, though my first cursory search only turned up the one I already mentioned.
Duplicate of:
Each language would most likely require different command line parsing code.
For C++ boost::program_options is a great choice.
For .Net you could check out this codeproject code.
For simple command line parsing see this MSDN page.
For C I don't know of any short of doing your own extra work.
You could start with this MSDN page.
Bob Martin (one of the most well-known and respected software guys out there) uses a command-line parser as a tutorial on writing clean code. This is one of his most lauded demonstrations - he has given it countless times in many countries. The end-product is nice, it's very easy and quick to follow along, and you learn a lot about clean coding practices along the way.
The example code is in Java, but it's intended for developers using any language and it's doled out in a few lines of code at a time, with heavy explanation.
I will have to second Brian's recommendation of boost.program_options. It is very good; I have used it before and is pretty easy and very customizable.
For C#, there's also this post.
And, I did a short series on command line option parsing for my InformIT column. It's not the end-all, but it's simple and I find it quite useful.
For .NET: Nini.
Not only does it do commandline option parsing, but you can load your commandline options from any standard configuration file (you could set commandline defaults in an INI or XML file, then have the switches override those defaults).
Setting up and retrieving parameters is fairly straight forward and gives you the options to define default values to return if nonspecified. If your doing anything remotely complex, the ability to outsource to a config file for those defaults can be invaluable too.