473,322 Members | 1,610 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

getopt

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

RR
Jul 19 '05 #1
6 15956
"Ramiro Rodriguez" <er********@yahoo.com> wrote in message
news:pa****************************@yahoo.com...
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

Jul 19 '05 #2
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.

Jul 19 '05 #3
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

Jul 19 '05 #4
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.

Jul 19 '05 #5
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.

Jul 19 '05 #6
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 |
+-----------------------------------------------------+

Jul 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: David Bear | last post by:
I'm stumped. Trying to follow the docs and .. failure. here's the args >>> args '-Middwb@mainex1.asu.edu -AKHAAM@prlinux+898 -CA --D2003-08-20-09:28:13.417 -Ff -Hprlinux...
4
by: Dan Rawson | last post by:
Is there any way to force getopt to process one option first?? I'd like to be able to pass in the name of a configuration file for my application, then have the remaining command-line parameters...
3
by: Dominik Kaspar | last post by:
I tried to use getopt and copied the example from: http://www.python.org/doc/current/lib/module-getopt.html but nothing is working... getopt.GetoptError doesn't seem to exist and when i run the...
3
by: Don Low | last post by:
Hi, I'm going over a script that demonstrates the getopt function. I include the script here: #! /usr/bin/python import sys, getopt, string
6
by: Frans Englich | last post by:
Hello, In my use of getopt.getopt, I would like to make a certain parameter mandatory. I know how to specify such that a parameter must have a value if it's specified, but I also want to make...
1
by: Andrew | last post by:
Dear Experts, I have a perl program that using Getopt:Std module, when I try to run the GetOpt program, the following error returned: Can’t locate Getopt.pm in @INC (@INC contains:...
14
by: José de Paula | last post by:
Is getopt() and its companions, commonly found in GNU libc and other Unices libc, part of the C standard? Another doubt: I have a switch inside a while loop; is there a way to break out of the...
4
by: pinkfloydhomer | last post by:
I want to be able to do something like: myscript.py * -o outputfile and then have the shell expand the * as usual, perhaps to hundreds of filenames. But as far as I can see, getopt can only...
1
by: Daniel Mark | last post by:
Hello all: I am using getopt package in Python and found a problem that I can not figure out an easy to do . // Correct input D:\>python AddArrowOnImage.py --imageDir=c:/ // Incorrect...
2
by: auditory | last post by:
I have sources written on linux quite long ago. They are compiled good on current linux machine. but not in VS2005. The cause of problem is #include<getopt.h>. Is there any correspoinding...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.