 <p>The following code:</p> <pre><code>while(i &lt; num_states) { &lt;---------------------- HERE printf("state %d: %s\n", i, states[i]); i--; } </code></pre> <p>You are actually counting down and checking <strong>incorrect</strong> value.</p> <p>Must be:</p> <pre><code> while(i &gt;= 0) </code></pre> <p>Here:</p> <pre><code>while(i &lt; argc) { printf("arg %d: %s\n", i, argv[i]); i--; } </code></pre> <p>The same:</p> <pre><code>while(i &gt;= 0) </code></pre>