title: Segmentation Fault: Why?
body: <p>I have this piece of code which compiles and works as expected:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  int fun(int* p){
      *p = 20;
      return 1;
  }
  
  int main(){
      int* number;    
      *number =10;
  
      cout &lt;&lt; "before: "&lt;&lt;*number&lt;&lt;endl;
      fun(number);
      cout &lt;&lt; "after: "&lt;&lt;*number&lt;&lt;endl;
      return 1;
  }
  </code></pre>
  
  <p>While the following one gives segmentation fault:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  int fun(int* p){
      *p = 20;
      return 1;
  }
  
  int main(){
      int test=1; //ADDITION
      int* number;    
      *number =10;
  
      cout &lt;&lt; "before: "&lt;&lt;*number&lt;&lt;endl;
      fun(number);
      cout &lt;&lt; "after: "&lt;&lt;*number&lt;&lt;endl;
      return 1;
  }
  </code></pre>
  
  <p>I am compiling using <code>g++ test.cpp -o test</code></p>
  
  <p>Can anybody explain me where this behaviour comes from?</p>