Dec 092017
 
Using Command line options. C-source.
File OPTIONS.ZIP from The Programmer’s Corner in
Category C Source Code
Using Command line options. C-source.
File Name File Size Zip Size Zip Type
OPTDEMO.C 1548 647 deflated
OPTIONS.C 2688 955 deflated
OPTIONS.H 512 256 deflated
READ.ME 896 447 deflated

Download File OPTIONS.ZIP Here

Contents of the READ.ME file


options() - provides unix-style command line option handling.

This means things like "foo -r bar" or "zap -xy afile".
The offered version only handles single character option specs.
It is easy to modify the table and procedure to handle
strings of arbitrary length (using strncmp). This version
works ok and uses less space.

Provision is made for auto invocation of a usage()
routine if no args are supplied. An example is included
in optdemo.c.

Options may be flagged as taking an argument or not. If
an arg is taken, this is passed to the appropriate function.
Otherwise a null string is passed.

Any non-option things left on the command line are left
there on the return to the caller. argc and argv are
adjusted as if there were never any options on the line.



 December 9, 2017  Add comments

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)