title: Store file pointer, and reset to that position based on condition?
body: <p>I am not able to understand how I can reset the file pointer to a previously stored position.</p>
  <p>Here is the actual problem in pseudocode:</p>
  <p>I am reading characters from a file <code>f</code> in some function A (B and C are some other functions):</p>
  <pre class="lang-cpp prettyprint-override"><code>      void A (fstream&amp; f) {
          char c = f.get();
          while (c == ' ' || c == '\n')
            c = f.get();
          while ( !&lt;C&gt; ) {
            B(c);          
            c = f.get();
            while (c == ' ' || c == '\n')
              c = f.get(); 
          }
          C(c);
          return;
        }
  </code></pre>
  <p>where the condition <code>\&lt;C&gt;</code> is that if c is the start with the regex:</p>
  <pre><code>     TT WS* ::=
  </code></pre>
  <p>where</p>
  <pre><code>    WS = {' ', '\n'}
  </code></pre>
  <p>it should return true, and the file pointer to f must still point to the first <code>T</code> in this regex. How do I implement <code>\&lt;C&gt;</code> as another function?</p>
  <p>Clearly to read the regex, I need to increment the file pointer, but then I need to reset it to the first <code>T</code>, how do I do this?</p>