Linux gperf C and C++ command line processing programming tutorial

by on July 29, 2007 · 2 comments· LAST UPDATED July 29, 2007

in , ,

GNU 'gperf' generates perfect hash functions. If a long option shows an argument as mandatory, then it is mandatory for the equivalent short option also. Use this tutorial for effective command-line processing in your C/C++ code:

Command-line processing is historically one of the most ignored areas in software development. Just about any relatively complicated software has dozens of available command-line options. In fact, it's not uncommon to find hundreds of lines of if-else statements coded to process user input, and maintenance of such legacy code becomes a time-consuming affair even for seasoned programmers. In such circumstances, most C developers commonly go for a rather long (and often nested) if-else statement with ANSI C library functions such as strcmp, strcasecmp, and strtok ...

The gperf utility is tuned to quickly generate a perfect hash for small to medium datasets. But gperf has other applications, as well. In fact, it's the tool of choice of maintaining perfect hashes for language keywords in GNU compilers, and recent advances allow you to work with larger datasets. So, consider making gperf part of your next development project.

GNU perfect (gperf) hash function generator makes short work of complex input strings

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 2 comments… read them below or add one }

1 raj December 6, 2007 at 10:35 am

I had installed linux fedora core,after installation is there any software to install for c++.plzzz provide sample code of c++ and the steps how to compile and execute the code in linux.

Reply

2 Arsalan January 23, 2008 at 10:34 am

plz tel me c/c++ code which play a .wav file.

Reply

Leave a Comment

Tagged as: , , , , , , , , ,

Previous post:

Next post: