title: In C, why can't an integer value be assigned to an int* the same way a string value can be assigned to a char*?
body: <p>I've been looking through the site but haven't found an answer to this one yet.</p>
  
  <p>It is easiest (for me at least) to explain this question with an example.</p>
  
  <p>I don't understand why this is valid:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(int argc, char* argv[])
  {
    char *mystr = "hello";
  }
  </code></pre>
  
  <p>But this produces a compiler warning ("initialization makes pointer from integer without a cast"):</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(int argc, char* argv[])
  {
    int *myint = 5;
  }
  </code></pre>
  
  <p>My understanding of the first program is that creates a variable called mystr of type pointer-to-char, the value of which is the address of the first char ('h') of the string literal "hello". In other words with this initialization you not only get the pointer, but also define the object ("hello" in this case) which the pointer points to.</p>
  
  <p>Why, then, does <code>int *myint = 5;</code> seemingly not achieve something analogous to this, i.e. create a variable called myint of type pointer-to-int, the value of which is the address of the value '5'? Why doesn't this initialization both give me the pointer and also define the object which the pointer points to?</p>