title: Redirecting stdin - C
body: <p>So I'm meant to accept a text file by doing the following command:</p>
  
  <pre><code>$ sort &lt; list.txt 
  </code></pre>
  
  <p>I understand that the list text file is being inputted to my sort program, but how do I actually use the information inside my program? How do I read it?</p>
  
  <p>My code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  int main(int argc, char** argv) {
  
      char c;   
  
      while (c != EOF){
          c = getchar();
          printf("%c ",c);
      }
  
     return (0);
  }
  </code></pre>
  
  <p>Example:</p>
  
  <pre><code>$ ./sort.c &lt; input.txt
  
  ./sort.c: line 3: $'\r': command not found
  
  ./sort.c: line 4: syntax error near unexpected token `('
  
  '/sort.c: line 4: `int main(int argc, char** argv) {
  </code></pre>