 <pre><code> while(token != NULL){ printf("%s\n", token); token = strtok(NULL, space); } </code></pre> <p>The while loop will fail when the token is <code>NULL</code>. At this time you are trying to print this pointer using your second <code>printf()</code> in the while loop which will lead to undefined behavior.</p> <p>Get rid of your second <code>printf()</code></p>