 <p>If they don't provide an argument, set that argument in <code>args</code> to <code>0</code>. Then <code>ls</code> won't receive an empty string as its first argument, it won't get any arguments at all.</p> <pre><code>args[0] = arg1; if (strlen(arg2) == 0) { args[1] = 0; } else { args[1] = arg2; args[2] = 0; } </code></pre> <p>You also need to check for this in the loop that prints all the arguments.</p> <pre><code>for(i=0;i&lt;MAX &amp;&amp; arg[i];i++) { printf("Value of arg[%d] =%s\n",i, args[i]); } </code></pre>