473,473 Members | 2,155 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 15963
"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: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.