title: C++ Different types of pointers
body: <p>in the following code I found that same pointer instruction crash the application in a situation while not in other situation.</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  int main()
  {
      int *p;
      *p = 50;                    //this instruction causes the crash
      int* q = new int;
      *q = 50;                    //this instruction executes ok
      cout &lt;&lt; "p:" &lt;&lt; p &lt;&lt; endl;
      cout &lt;&lt; "q:" &lt;&lt; q &lt;&lt; endl;
      return 0;
  }
  </code></pre>
  
  <p>I want to know why this is the case?</p>