You are not logged in.

#1 2010-08-12 14:13:12

Google
Member
From: Mountain View, California
Registered: 2010-05-31
Posts: 484
Website

C Programming, command line parsing...

I am using getopt() and a switch to parse my input, as shown over at:

http://www.gnu.org/s/libc/manual/html_n … -of-Getopt

I have read about parsing, but I can't parse something the way I want. I want to have a final variable on the command line.

For example: $programname -a -d 4560

However the 4560 is _not_ related to -a or -d, it is entirely on its own and it must come last. I am not sure how I would 'catch' the argument in a switch, and how I could ensure it's the final argument?

My string const in getopt() is like this: "a:d::"

a requires an argument, -d is optional, but now I need a final integer value that doesn't have a flag, just a number... any ideas?

Offline

#2 2010-08-12 19:44:48

Inxsible
Forum Fellow
From: Chicago
Registered: 2008-06-09
Posts: 9,183

Re: C Programming, command line parsing...

Closing duplicate....

Follow discussion here


Forum Rules

There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !

Offline

Board footer

Powered by FluxBB