title: C echo user input
body: <p>So I am a very beginner to C programming (I have used Ruby, Python and Haskell before) and I am having trouble getting the most simple thing to work in C (probably because of all the manual memory stuff). Anyway, what I am trying to do is (using simple constructs) make a script that just echoes what the user inputs to the console. </p>
  
  <p>e.g. user inputs hi, console prints hi.</p>
  
  <p>This is what I came up with. </p>
  
  <p>Also, I haven't really mastered pointers, so none of that.</p>
  
  <pre><code>// echo C script
  
  int echo();
  
  int main() {
  
      echo();
      return 0;
  
  }
  
  int echo() {
      char input[500];
  
      while (1) {
          if (scanf("%[^\n]", input) &gt; 0) {
              printf("%s\n", input);
          }
          input[0] = 0;
      }
      return 1;
  }
  </code></pre>
  
  <p>I realize that there is a bunch of bad practices here, like setting a giant string array, but that is just for simplifying it.</p>
  
  <p>Anyway, my problem is that it repeats the first input then the input freezes. As far as I can tell, it freezes during the while loop (1 is never returned).</p>
  
  <p>Any help would be appreciated.</p>
  
  <p>Oh, and using TCC as the compiler.</p>