title: file pointer and using fgets
body: <p>gcc 4.4.4 c89</p>
  
  <p>I am reading in a file and in that file I have to do some operation on each line.</p>
  
  <p>In a loop I call a 2 functions that pass in this file pointer to perform 2 different operations on the file.</p>
  
  <p>However, as I am using fgets to read in a line of that text file. It automatically increments to the next line. So for the second call, it has already incremented. However, I want to perform a different operation on the same line as the first function. </p>
  
  <pre><code>FILE *fp = NULL;
  fp = fopen("devices.txt", "r");
  for each line
      get_devicename(fp); &lt;-- calls fgets and operates on line 1, then increments to line 2
  
      get_machine_code(fp); &lt;-- calls gets and already on line 2, I need line 1
  end for
  </code></pre>
  
  <p>To have a work around, I created 2 file pointers objects and passed them to the functions. However, in the future I might need more operations to do on this text file. So not very scalable if I have to keep creating instances of the file pointer.</p>
  
  <p>Many thanks for any suggestions,</p>