 <p><code>char *str = "foo"</code> gives you a pointer to a string literal (you should really be doing <code>const char *</code>, but C allows non-<code>const</code> for backwards compatiblity reasons).</p> <p>It is undefined behaviour to attempt to modify a string literal. <code>strtok</code> modifies its input.</p>