title: Segmentation fault error in c++ program
body: <p>There is a c++ code below.  </p>
  
  <pre><code>#include&lt;iostream&gt;
  #include &lt;cstring&gt;
  using namespace std;
  void f(const char* s)
  {
      char* temp;
      strcpy(temp,s);
  
      cout&lt;&lt;temp&lt;&lt;endl;
  }
  int main()
  {
      f("HELLO");
      return 0;
  }
  </code></pre>
  
  <p>When I compile it:  </p>
  
  <pre><code>g++ -o output main.cpp
  </code></pre>
  
  <p>It compiles without any error. But when I run it with <code>./output</code><br>
  it gives an error  <strong>Segmentation fault (core dumped)</strong><br>
  What is the problem??<br>
  PS:<br>
  OS is Ubuntu 14.04 LTS</p>