Connecting Tech Pros Worldwide Help | Site Map

getopt

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 19th, 2005, 07:12 PM
Ramiro Rodriguez
Guest
 
Posts: n/a
Default getopt

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

RR

  #2  
Old July 19th, 2005, 07:12 PM
Mike Wahler
Guest
 
Posts: n/a
Default 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



  #3  
Old July 19th, 2005, 07:12 PM
Stewart Gordon
Guest
 
Posts: n/a
Default 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.

  #4  
Old July 19th, 2005, 07:14 PM
Sean Fraley
Guest
 
Posts: n/a
Default 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

  #5  
Old July 19th, 2005, 07:15 PM
Stewart Gordon
Guest
 
Posts: n/a
Default 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.

  #6  
Old July 19th, 2005, 07:16 PM
E. Robert Tisdale
Guest
 
Posts: n/a
Default 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.

  #7  
Old July 19th, 2005, 07:20 PM
Lorenzo Bettini
Guest
 
Posts: n/a
Default 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 |
+-----------------------------------------------------+

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,840 network members.