K
Karthik
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]
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]