title: Input with char pointer vs. char array
body: <p>consider the code</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  int main(void)
  {
     char* a;
     scanf("%s",a);//&amp;a and &amp;a[0] give same results-crashes 
     printf("%s",a);
     return 0;
  }
  </code></pre>
  
  <p>why does this code results in crashing?whereas this code using character array works fine?</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  int main(void)
  {
     char a[100];
     scanf("%s",&amp;a[0]);//works fine
     printf("%s",a);
     return 0;
  }
  </code></pre>
  
  <p>the difference being character array and pointer?but i knew that pointer just points to the first element that is &amp;a[0] should work fine but upper code crashes for all three that is a,&amp;a and &amp;a[0]?
  the main thing i would to gather is how can i take input of a character pointer if i insist on using scanf only?
  i apologize if i am not clear.
  thanks in advance:) </p>