title: cannot copy command line argument to character pointer in C
body: <p>I am taking command line argument which I am copying to my character pointer. but its giving me an error.</p>
  
  <pre><code>int main(int argc, char *argv[])
  {
      char *cmdarg;
      if(argc&gt;1)
              strcpy(cmdarg, argv[1]);
      else
              cmdarg = NULL;
      return 0;
  }
  </code></pre>
  
  <p>This gives me</p>
  
  <pre><code>Segmentation fault (core dumped)
  </code></pre>