<div dir="ltr">Yeah, for the optstring the colon means you need to specify something with that individual switch, which doesn&#39;t apply to this project since the file/folder operands apply to the program itself, not the individual switches.<div><br></div><div>If you check out the manpage for getopt(3), it has examples of how the colon works.</div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Oct 13, 2017 at 1:14 PM mseaton &lt;<a href="mailto:mseaton@stevens.edu">mseaton@stevens.edu</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Jason,<br>
<br>
Yeah, I am referring to the opstring of getopt(3) as well the operands.<br>
For example: (ls -a) and (ls -a DIRNAME) should both work. getopt(3)<br>
says that you must place a &quot;:&quot; after an option if it should return an<br>
argument. By doing this, ls -a won&#39;t work.<br>
I guess you are saying I should not place a &quot;:&quot; after any of the command<br>
options. In which case I won&#39;t have to worry about optarg which was what<br>
I used to determine if an argument was entered or not.<br>
<br>
Thanks.<br>
Marlon<br>
On 10/13/2017 11:15 AM, Jason Ajmo wrote:<br>
&gt; I&#39;m not sure if you&#39;re referring to the optstring for getopt(3) or the<br>
&gt; program operands, but neither are required. You should specify your<br>
&gt; optstring in a way that won&#39;t error if no options are supplied.<br>
&gt;<br>
&gt; getopt(3) doesn&#39;t process the operands; just the command line<br>
&gt; switches. That&#39;s why, after getopt(3) is done, you need to decrement<br>
&gt; argc, and increment argv to get the proper starting point of the<br>
&gt; operands.<br>
&gt;<br>
&gt; On Fri, Oct 13, 2017 at 11:11 AM mseaton &lt;<a href="mailto:mseaton@stevens.edu" target="_blank">mseaton@stevens.edu</a>&gt; wrote:<br>
&gt;<br>
&gt;&gt; Hello,<br>
&gt;&gt;<br>
&gt;&gt; I understand setting opterr to zero means that getopt will not<br>
&gt;&gt; report an<br>
&gt;&gt; error if no argument is entered, but our options must be able to<br>
&gt;&gt; work in<br>
&gt;&gt; both cases, however it still does not allow the program to continue<br>
&gt;&gt; if<br>
&gt;&gt; no argument is entered.<br>
&gt;&gt;<br>
&gt;&gt; Is there something I am missing?<br>
&gt;&gt; Thanks<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; cs631apue mailing list<br>
&gt;&gt; <a href="mailto:cs631apue@lists.stevens.edu" target="_blank">cs631apue@lists.stevens.edu</a><br>
&gt;&gt; <a href="https://lists.stevens.edu/mailman/listinfo/cs631apue" rel="noreferrer" target="_blank">https://lists.stevens.edu/mailman/listinfo/cs631apue</a> [1]<br>
&gt;<br>
&gt; --<br>
&gt;<br>
&gt; Jason Ajmo<br>
&gt; Stevens Institute of Technology<br>
&gt; B.S. Cybersecurity &#39;17<br>
&gt; M.S. Computer Science &#39;18<br>
&gt; 0x56FA3123<br>
&gt;<br>
&gt; Links:<br>
&gt; ------<br>
&gt; [1] <a href="https://lists.stevens.edu/mailman/listinfo/cs631apue" rel="noreferrer" target="_blank">https://lists.stevens.edu/mailman/listinfo/cs631apue</a><br>
</blockquote></div><div dir="ltr">-- <br></div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>Jason Ajmo</div><div>Stevens Institute of Technology</div><div>B.S. Cybersecurity &#39;17</div><div>M.S. Computer Science &#39;18</div><div>0x56FA3123</div></div></div>