Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > getopt

Reply
Thread Tools

getopt

 
 
Ramiro Rodriguez
Guest
Posts: n/a
 
      10-14-2003
In C there is a function to easily parse command line arguments called
getopt. Is there such a function in c++

RR
 
Reply With Quote
 
 
 
 
Mike Wahler
Guest
Posts: n/a
 
      10-14-2003
"Ramiro Rodriguez" <(E-Mail Removed)> wrote in message
news(E-Mail Removed)...
> 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



 
Reply With Quote
 
 
 
 
Stewart Gordon
Guest
Posts: n/a
 
      10-14-2003
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.

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

 
Reply With Quote
 
Sean Fraley
Guest
Posts: n/a
 
      10-15-2003
Ramiro Rodriguez wrote:

> 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

 
Reply With Quote
 
Stewart Gordon
Guest
Posts: n/a
 
      10-15-2003
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>
> 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.

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

 
Reply With Quote
 
E. Robert Tisdale
Guest
Posts: n/a
 
      10-16-2003
Ramiro Rodriguez wrote:

> In C, there is a function to easily parse command line arguments
> called getopt.


I don't think so.

> Is there such a function in C++


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.

 
Reply With Quote
 
Lorenzo Bettini
Guest
Posts: n/a
 
      10-17-2003
Ramiro Rodriguez wrote:
> 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 |
+-----------------------------------------------------+

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is getopt() standard C? etc. =?iso-8859-1?q?Jos=E9_de_Paula?= C Programming 14 02-04-2004 11:33 AM
getopt Spartan815 C Programming 2 01-26-2004 05:36 AM
Problem with Getopt Arvind Kumar Perl 1 11-03-2003 06:50 PM
Re: Dealing with fragmented getopt parameters Jem Berkes C Programming 2 10-30-2003 02:50 AM
command args processing lib(a la getopt), anyone? dima C++ 9 09-05-2003 01:10 AM



Advertisments