473,406 Members | 2,387 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,406 software developers and data experts.

getopt_long() problems

hi everyone,

I am using getopt_long() in one of my programs to parse out the
command line arguments.

The library call returns a character code of "1" which i am not sure
whether it is a errno or what it is.

The code snippet is :

---code---

static struct option const long_opts[] =
{
{"directory", no_argument, NULL, 'd'},
{"force", no_argument, NULL, 'f'},
{"interactive", no_argument, NULL, 'i'},
{"recursive", no_argument, NULL, 'r'},
{"verbose", no_argument, NULL, 'v'},
{NULL, 0, NULL, 0}
};
.......
.......

int c = 0;

while ((c = getopt_long (argc, argv, "dfirvR", long_opts, NULL)) !=
EOF)
{
fprintf(stderr,"Value of c is : %d \n",c);

switch(c) {
.....

default:
fprintf(stderr,"I am here 1\n");
usage (1);

}
}

---code---
Output from the program: [partial ..coz rest is not needed in this
case]

---output---

Value of c is : 1
I am here 1

[usage text ]

---output---

Actually the usage text is being displayed multiple times ..say like
10 times or something. I am really confused and dont know what to do.
Any help is highly appreciated.

TIA

Karthik

ps: plz cc a reply to my email address also [k_mohanas AT yahoo DOT
com]
Nov 14 '05 #1
2 3708
Karthik wrote:

I am using getopt_long() in one of my programs to parse out the
command line arguments.
.... snip ...
ps: plz cc a reply to my email address also [k_mohanas AT yahoo
DOT com]


getopt is not a part of standard C. Maybe comp.unix.programmer?
And you should not expect direct e-mails, especially when you hide
your address. If the reply-to: field was set correctly you MIGHT
get the occasional direct reply, but in general the rule is "ask
here, read here".

--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!

Nov 14 '05 #2
CBFalconer wrote:
Karthik wrote:
I am using getopt_long() in one of my programs to parse out the
command line arguments.


... snip ...
ps: plz cc a reply to my email address also [k_mohanas AT yahoo
DOT com]

getopt is not a part of standard C. Maybe comp.unix.programmer?
And you should not expect direct e-mails, especially when you hide
your address. If the reply-to: field was set correctly you MIGHT
get the occasional direct reply, but in general the rule is "ask
here, read here".


Thanx for the suggestion. This is my first post to a USENET group and i
was not sure how to go about doing everything. Now i kinda figured it
out. Will not request a direct reply next time.

Karthik

Nov 14 '05 #3

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

Similar topics

14
by: Jim Hubbard | last post by:
Are you up to speed on the difficulties in using the 1.1 .Net framework? Not if you are unaware of the 1,596 issues listed at KBAlertz (http://www.kbalertz.com/technology_3.aspx). If you are...
1
by: 3f | last post by:
Hello; We have made a web application that people can download from our web site and installed on: Windows XP Windows 2000 Professional Windows 2003 Server Windows 2000 Server
5
by: Corky | last post by:
This works: db2 SELECT DISTINCT PROBLEM_OBJECTS.PROBLEM_ID FROM PROBLEM_OBJECTS INNER JOIN PROBLEMS ON PROBLEM_OBJECTS.PROBLEM_ID = PROBLEMS.PROBLEM_ID WHERE INTEGER(DAYS(CURRENT DATE) -...
2
by: jenea | last post by:
HI! I write a little test program. In witch I use getopt_long function... I included unstd.h , optget.h , stdio.h and stdlib.h when i try to link the program with gcc -o result main.o ( within...
10
by: BBFrost | last post by:
We just recently moved one of our major c# apps from VS Net 2002 to VS Net 2003. At first things were looking ok, now problems are starting to appear. So far ... (1) ...
2
by: Brian | last post by:
NOTE ALSO POSTED IN microsoft.public.dotnet.framework.aspnet.buildingcontrols I have solved most of my Server Control Collection property issues. I wrote an HTML page that describes all of the...
1
by: Angel Tsankov | last post by:
Does anyone know of a port of getopt and getopt_long for Windows, especially one that compiles and links with VC++?
0
by: Sergistm | last post by:
Hello World, :D I have a problem that it is making me crazy, I hope you can help me. I'm trying to execute a .exe file with the Procces.Start, and there is no problem when the file is on my...
1
by: ff0000 | last post by:
Hi everyone, Preamble: i'm a newbie :-) I've a doubt about the behaviour of variable "hasarg" in the option struct (from getopt(3)): struct option { const char *name; int has_arg;...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.