title: Is there a way to rewind stdin in C?
body: <p>So my code should look through a text file via command line with</p>
  
  <pre><code> ./program &lt; text.txt
  </code></pre>
  
  <p>This way of executing the program is important for my purposess.</p>
  
  <p>but after going through it once every other method already looks at the end of the text file.</p>
  
  <p>Im trying to go through a provided text file but once a function reads it once, probably the pointer already stays at the end of the file and other functions dont work anymore.</p>
  
  <p>So there is the most basic function that uses this.
  Once i try any other function with the same for cycle it just doesnt work anymore. I suppose its the pointer but i havent been successful with finding a way to refresh it.</p>
  
  <pre><code>void writeOut()
  {
      char line[100];
      for(; fgets(line, 100, stdin) != NULL;)
      {
          fprintf(stdout,"%s", line);
  
      }
      fprintf(stdout,"\n");
  }
  </code></pre>
  
  <p>I expect to be able to read through the same file multiple times and be able to "flush" the memory of fgets().</p>
  
  <p>Thanks for any useful input</p>