title: Why is my C program not printing out the string?
body: <p>I am am making a program that prints out what the user types in, and it needs to be done with the method <code>read_line()</code> (for my homework), so I can't change too much.</p>
  
  <p>I don't understand why it isn't printing out what the user enters.</p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  
  char *read_line(char *buf, size_t sz) {
    char tempBuf[sz];
    char c;
    int pos = 0;
  
    printf("&gt; ");
  
    while(1) {
      c = getchar();
      if (tempBuf[pos] == EOF || tempBuf[pos] == '\n') {
        buf = tempBuf;
        return buf;
      } else {
        tempBuf[pos] = c;
      }
      pos++;
    }
  }
  
  int main(int argc, char **argv) {
    char *buf;
    char *input = read_line(buf, 128);
  
    printf("Here: %s", input);
  }
  </code></pre>
  
  <p>I am new to C and I am finding it very confusing, so please explain anything in pretty simple terms. Any help would be much appreciated.</p>