title: Scanning in a string using pointers in C
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2329909/dynamic-string-input-using-scanfas">Dynamic String Input - using scanf(“%as”)</a><br>
    <a href="https://stackoverflow.com/questions/13253113/strcmp-with-pointers-not-working-in-c">strcmp with pointers not working in C</a>  </p>
  </blockquote>
  
  
  
  <p>Is the following considered good code?  Shouldn't I have used malloc somewhere?  I was able to compile this and it worked, but I feel like it shouldn't have.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main (void) {
  
      char *name;
  
      printf("Whats your name? ");
      scanf("%s", &amp;name);
      printf("\nyour name is %s", &amp;name);
  
      return 0;
  }
  </code></pre>
  
  <p>What happens if I want to modify name?  How would I go about doing so?</p>
  
  <p>Edit:  I am really just looking for the most efficient and correct way to do this using pointers.  I am assuming malloc is necessary.  </p>