[techtalk] switch function in C (or how to read commandline args?)

Jeff Dike jdike at karaya.com
Sat Jun 30 17:56:28 EST 2001


jas88 at cam.ac.uk said:
> What you can do is switch() on the FIRST character of the word, then
> use strcmp() to check for each possibility - something like this:

Yuck.  Argument parsing is not a performance problem.  If you want to roll 
your own code, then just do a chain of strcmps (and if you feel like 
optimizing that, stick the commonly used options first).  If you don't,

> You can do something similar using the GNU getopt library

				Jeff






More information about the Techtalk mailing list