title: What is causing my print statements to produce different results?
body: <p>I'm a newbie learning to program in  C, and I am currently working on creating a program that takes a name input from a user then prints that name back on to the screen. When the program prints out the name in the else if block, what I get is $ ". I want to know why it happens and how I might correct this problem. My code is as follows: </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  int main() {
      char * ans; // yes/no answer
      char * name; //name variable
  
      printf("Welcome to the program. Would you like to begin? (y/n)\n");
      scanf("%s", ans);
  
      if (strcmp(ans, "y") != 0) {
          printf("Have a good day!\n");
          return 0;
      }
      else if (strcmp(ans, "y") == 0)
          printf(" %s\n", ans);
  
      printf("Okay, input your name:\n");
      scanf("%s", name);
  
      printf(" %s", name);// I get $ " rather than the name.
  
      return 0;
  }
  </code></pre>