c - getopt switch statement never hitting default case -
i've tried searching , haven't found duplicate/similar question.
how come "default" never triggering in case? working on previous homework assignments course of study prepare fall, , i'm having issue getopt() in c.
here particular lines in question:
while ((c = getopt(argc, argv, "i:o:")) != -1) { switch (c) { case 'i': infile = strdup(optarg); break; case 'o': outfile = strdup(optarg); break; default: usage(); //this prints "usage" statement , exits cleanly. } } my issue is, how come calling
./fastsort b c d doesn't print usage , exit?
the below code search options -i hello or/and -o world
while((c = getopt(argc, argv, "i:o:") != -1) however executing is:
./fastsort b c d where getopt(argc, argv, "i:o:") != -1 not satisfied since none of passed argument a b c dis option
c command-line-arguments getopt
No comments:
Post a Comment