Connecting Tech Pros Worldwide Help | Site Map

getopt

Ramiro Rodriguez
Guest
 
Posts: n/a
#1: Jul 19 '05
In C there is a function to easily parse command line arguments called
getopt. Is there such a function in c++

RR
Mike Wahler
Guest
 
Posts: n/a
#2: Jul 19 '05

re: getopt


"Ramiro Rodriguez" <ergodicsum@yahoo.com> wrote in message
news:pan.2003.10.14.12.14.17.865085@yahoo.com...[color=blue]
> In C there is a function to easily parse command line arguments called
> getopt.[/color]

No there is not. Your implementation might
provide one as an extension, but it's not
part of standard C.
[color=blue]
>Is there such a function in c++[/color]

No. If you decide to try to write one, we
can help.

-Mike



Stewart Gordon
Guest
 
Posts: n/a
#3: Jul 19 '05

re: getopt


While it was 14/10/03 1:14 pm throughout the UK, Ramiro Rodriguez
sprinkled little black dots on a white screen, and they fell thus:
[color=blue]
> In C there is a function to easily parse command line arguments called
> getopt. Is there such a function in c++[/color]

IINM, C++ can call any C function.

But I'm not sure that getopt is part of standard C or C++.

But quite recently I wrote a command line reader class that might be to
your needs (depending on what your needs are). I'll try and get it put
up somewhere soon.

Stewart.

--
My e-mail is valid but not my primary mailbox. Please keep replies on
on the 'group where everyone may benefit.

Sean Fraley
Guest
 
Posts: n/a
#4: Jul 19 '05

re: getopt


Ramiro Rodriguez wrote:
[color=blue]
> In C there is a function to easily parse command line arguments called
> getopt. Is there such a function in c++
>
> RR[/color]

1) getopt is part of the POSIX standard, not the ANSI C OR C++ standards.

2) You should be able to call it from a C++ program with no problems.

Sean

Stewart Gordon
Guest
 
Posts: n/a
#5: Jul 19 '05

re: getopt


While it was 14/10/03 3:23 pm throughout the UK, Stewart Gordon
sprinkled little black dots on a white screen, and they fell thus:

<snip>[color=blue]
> But quite recently I wrote a command line reader class that might be to
> your needs (depending on what your needs are). I'll try and get it put
> up somewhere soon.[/color]

It's now up, complete with a bit of documentation (just under 8K in total):

http://www.smjg.ableinternet.com/misc/clr.tar.gz

Stewart.

--
My e-mail is valid but not my primary mailbox. Please keep replies on
on the 'group where everyone may benefit.

E. Robert Tisdale
Guest
 
Posts: n/a
#6: Jul 19 '05

re: getopt


Ramiro Rodriguez wrote:
[color=blue]
> In C, there is a function to easily parse command line arguments
> called getopt.[/color]

I don't think so.
[color=blue]
> Is there such a function in C++[/color]

I used Google

http://www.google.com/

to search for

+"C++" +"class GetOpt"

and found lots of stuff including
C++ version of the GNU getopt function
http://cclib.nsu.ru/projects/gnudocs...libg++_39.html

Hope this helps.

Lorenzo Bettini
Guest
 
Posts: n/a
#7: Jul 19 '05

re: getopt


Ramiro Rodriguez wrote:[color=blue]
> In C there is a function to easily parse command line arguments called
> getopt. Is there such a function in c++[/color]

you may want to try GNU Gengetopt that I personally maintain:

http://www.gnu.org/software/gengetopt/

This program generates a C function that uses getopt_long function to
parse the command line options, to validate them and fills a struct

I use it also inside C++ programs :-)

hope this helps
Lorenzo

--
+-----------------------------------------------------+
| Lorenzo Bettini ICQ# lbetto, 16080134 |
| PhD in Computer Science |
| Dip. Sistemi e Informatica, Univ. di Firenze |
| Tel +39 055 4796741, Fax +39 055 4796730 |
| Florence - Italy (GNU/Linux User # 158233) |
| Home Page : http://www.lorenzobettini.it |
| http://music.dsi.unifi.it XKlaim language |
| http://www.lorenzobettini.it/purple Cover Band |
| http://www.gnu.org/software/src-highlite |
| http://www.gnu.org/software/gengetopt |
| http://www.lorenzobettini.it/software/gengen |
+-----------------------------------------------------+

Closed Thread