title: Echoing Standard input to Standard Output
body: <p>Write a program that will read standard input and echo each line to standard output with a line number and tab preceding it. When you run this program and enter lines from the terminal, lines of input will be interspersed with lines of output. If your system has output redirection and you redirect output to a file, the file will look like the input with the lines numbered.</p>
  
  <p>Here is an example of how the script should work.</p>
  
  <p>User input in <strong>bold.</strong></p>
  
  <p>Enter your text:</p>
  
  <p><strong>This is line 1.</strong></p>
  
  <p>1     This is line 1.</p>
  
  <p><strong>This is line 2.</strong></p>
  
  <p>2     This is line 2.</p>
  
  <p><strong>This is the last line of input.</strong></p>
  
  <p>3     This is the last line of input.</p>
  
  <p>The last line will end the process.</p>
  
  <p>Here is what I have so far:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  int main()
  {
      printf("Enter your text: \n");
      while (1)
      {
          int ch = getc(stdin);
          fflush(stdout);
          if(ch == EOF) break;
  
          putc(ch, stdout);
      }
      return 0;
  }
  </code></pre>
  
  <p>I have been attempting at this for a few hours now to no luck, any help is appreciated. I basically cant get my script to display the example output. I can get my script to display the stdin as an stdout and thats all. This is a C assignment.</p>