getopt

R

Ramiro Rodriguez

In C there is a function to easily parse command line arguments called
getopt. Is there such a function in c++

RR
 
M

Mike Wahler

Ramiro Rodriguez said:
In C there is a function to easily parse command line arguments called
getopt.

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

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

-Mike
 
S

Stewart Gordon

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:
In C there is a function to easily parse command line arguments called
getopt. Is there such a function in c++

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.
 
S

Sean Fraley

Ramiro said:
In C there is a function to easily parse command line arguments called
getopt. Is there such a function in c++

RR

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
 
S

Stewart Gordon

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:

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.

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.
 
L

Lorenzo Bettini

Ramiro said:
In C there is a function to easily parse command line arguments called
getopt. Is there such a function in c++

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 |
+-----------------------------------------------------+
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top