Convert and store integer into char pointer
<p>I am trying to convert and store an integer into a char pointer. So far this is what I have.</p>

<pre><code>char * str1;
sprintf(str1,"%d",10);
</code></pre>

<p>I keep getting a <code>Segmentation fault</code> error.</p>

<p>If the code below works then why doesn't the above?</p>

<pre><code>char * str1;
str1 = "Hello World";
printf("%s\n", str1);
</code></pre>