[cs631apue] overriding the no argument condition in getopt

Jason Ajmo jajmo at stevens.edu
Fri Oct 13 11:15:25 EDT 2017


I'm not sure if you're referring to the optstring for getopt(3) or the
program operands, but neither are required. You should specify your
optstring in a way that won't error if no options are supplied.

getopt(3) doesn't process the operands; just the command line switches.
That's why, after getopt(3) is done, you need to decrement argc, and
increment argv to get the proper starting point of the operands.

On Fri, Oct 13, 2017 at 11:11 AM mseaton <mseaton at stevens.edu> wrote:

> Hello,
>
> I understand setting opterr to zero means that getopt will not report an
> error if no argument is entered, but our options must be able to work in
> both cases, however it still does not allow the program to continue if
> no argument is entered.
>
> Is there something I am missing?
> Thanks
> _______________________________________________
> cs631apue mailing list
> cs631apue at lists.stevens.edu
> https://lists.stevens.edu/mailman/listinfo/cs631apue
>
-- 
Jason Ajmo
Stevens Institute of Technology
B.S. Cybersecurity '17
M.S. Computer Science '18
0x56FA3123
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.stevens.edu/pipermail/cs631apue/attachments/20171013/f9f8c725/attachment.html>


More information about the cs631apue mailing list