title: Pointers and access to memory in c. Be careful
body: <p>Still learning more C and am a little confused. In my references I find cautions about assigning a pointer that has not been initialized. They go on to give examples. Great answers yesterday by the way from folks helping me with pointers, here:</p>
  
  <p><a href="https://stackoverflow.com/questions/54012242/precedence-parentheses-pointers-with-iterative-array-functions">Precedence, Parentheses, Pointers with iterative array functions</a></p>
  
  <p>On follow up I briefly asked about the last iteration of the loop and potentially pointing the pointer to a non-existent place (i.e. because of my references cautioning against it). So I went back and looked more and find this:</p>
  
  <p>If you have a pointer</p>
  
  <pre><code>int *pt;
  </code></pre>
  
  <p>then use it without initializing it (i.e. I take this to mean without a statement like <code>*pt= &amp;myVariable</code>):</p>
  
  <pre><code>*pt = 606;
  </code></pre>
  
  <p>you could end up with a real bad day depending on where in memory this pointer has been assigned to. The part I'm having trouble with is when working with a string of characters something like this would be ok:</p>
  
  <pre><code>char *str = "Sometimes I feel like I'm going crazy.";
  </code></pre>
  
  <p>Where the reference says, "Don't worry about where in the memory the string is allocated; it's handled automatically by the compiler". So no need to say initialize <code>*str = &amp;str[0];</code> or <code>*str = str;</code>. Meaning, the compiler is automatically <code>char str[n];</code> in the background?</p>
  
  <p>Why is it that this is handled differently?  Or, am I completely misunderstanding?</p>