getopt_long() problem
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > getopt_long() problem




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    getopt_long() problem  
Karthik


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 10:23 PM

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]





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 01:27 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register