getopt: how to carry more than one argument?

Z

zwylinux

while ((c = getopt (argc, argv, ":a:")) != -1) {
switch (c)
case 'a':
v_a = 1;
a_list = optarg;
break;
............
............
}

printf ("%s\n", a_list);

the output is:
$./a.out -a aa bb
aa

so bb is missing, but i suppose aa and bb are both arguments of option
-a.
How can I do that?
 
J

Jack Klein

while ((c = getopt (argc, argv, ":a:")) != -1) {
switch (c)
case 'a':
v_a = 1;
a_list = optarg;
break;
............
............
}

printf ("%s\n", a_list);

the output is:
$./a.out -a aa bb
aa

so bb is missing, but i suppose aa and bb are both arguments of option
-a.
How can I do that?

There is no getopt() function in the C standard, so its definition and
use if not topical here. I would suggest asking in a group that
supports your particular compiler, or perhaps
or if
either of these is your platform.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top