Click to See Complete Forum and Search --> : Command line switches in C


Hena
09-12-2001, 06:23 AM
Can someone show me a nice way to do unix-like switches, in C, for programs done in command line. Eg.

prog -sw1 cmd1 -sw2 cmd2 -sw3 cmd3

jemfinch
09-12-2001, 06:26 AM
http://www.codeexamples.org/ is your friend...

Jeremy

The Kooman
09-12-2001, 07:50 AM
Originally posted by Hena:
<STRONG>Can someone show me a nice way to do unix-like switches, in C, for programs done in command line. Eg.

prog -sw1 cmd1 -sw2 cmd2 -sw3 cmd3</STRONG>

Also take a look at the getopt library - typically man 3 getopt.

Hena
09-12-2001, 08:36 AM
Got it to work now, thanks :)

Ben Briggs
09-12-2001, 10:09 AM
Originally posted by The Kooman:
<STRONG>Also take a look at the getopt library - typically man 3 getopt.</STRONG>

" http://www.codeexamples.org/ is your friend..."

:)