title: How does int *p = 10; work?
body: <p>I have a statement <code>int *p = 10;</code> . This statement executes perfectly fine on any compiler. I also know that 10 is put in read-only memory. Is there a way i can access this memory. How can I print this on console? The statement <code>printf("%d",*p)</code> crashes. How can I make it print on console.</p>
  
  <p>Edit</p>
  
  <pre><code>int main()
  {
     int *p = 10;
  }
  </code></pre>
  
  <p>the above code compiles fine and runs fine.</p>
  
  <pre><code>int main()
  {
      int *p = 10;
      printf("\n%d",*p); //crashes
  }
  </code></pre>
  
  <p>the above code gives segmentation fault. I wanted to know more explanation on this?</p>