What does directly setting a pointer with a variable means? : <p>PS, I know what a pointer is and how to use one, but confused on one thing. I have already tried searching stackoverflow on this question:</p>

<pre><code>int *ptr = 20 //why illegal or seg fault or crash?
printf("%i", *ptr) // Seg Fault
printf("%i", ptr) // Output -&gt; 20
printf("%p", &amp;ptr) // Returns a valid address.   
</code></pre>

<p>and found that, By directly assigning a value to a pointer without initializing with malloc or null, means that we are saying to the compiler, Hey CPU, Make a space in the memory to store an integer at the exact address given as value, which in this case 20. So basically saying to the compiler make a place for an INT in the ram with the address 20. By doing this we are touching system memory or illegal space.</p>

<p>But what I don't get is, </p>

<ol>
<li><blockquote>
  <p>How the integer 20 can directly be referenced as a memory?</p>
</blockquote></li>
<li><blockquote>
  <p>What happens when we do the same for float or char? for example float *ptr = 20.25</p>
</blockquote></li>
<li><blockquote>
  <p>I tried directly converting c code to assembly with a website, for a legal and illegal pointer example, where I see that the same registers are called, same MOV operations are done, And no explicit "MAKE SPACE AT given ADDRESS" instructions  were set.</p>
</blockquote></li>
<li>Lastly, What exactly happens when we declare strings by doing char
*ptr = "Hello"?</li>
</ol>

<p>I have tried every possible way to understand this, but couldn't. Can you guys point me to the right direction? Thanks ...</p>
