title: Pointer initialisation gives segmentation fault
body: <p>I wrote a C program as follows:</p>
  
  <h2>CASE 1</h2>
  
  <pre><code>int *a; /* pointer variable declaration */
  
  int b; /* actual variable declaration */
  
  *a=11;
  
  a=&amp;b;/* store address of b in pointer variable*/
  </code></pre>
  
  <p>It gives a segmentation fault when running the program.</p>
  
  <p>I changed the code as follows:</p>
  
  <h2>CASE 2</h2>
  
  <pre><code>int *a; /* pointer variable declaration */
  
  int b; /* actual variable declaration */
  
  a=&amp;b;/* store address of b in pointer variable*/
  
  *a=11;
  </code></pre>
  
  <p>Now it's working fine.</p>
  
  <p>If anyone knows please explain why it is giving a segmentation fault in CASE 1.</p>