title: C++ equivalent of fscanf()?
body: <p>And please don't say it's fscanf() ;P</p>
  
  <p>I'm trying to replace this line:</p>
  
  <pre><code>if ( fscanf(fp, "P%c\n", &amp;ch) != 1 )
  </code></pre>
  
  <p>If I understand correctly, it tries to read in a char and store it to &amp;ch, only if it's between a 'P' and  a '\n'. Is that right?
  And if it succeeds, it returns 1 (the number of characters it read)?</p>
  
  <p>I'm trying to come up with a C++ version. Is there any easy way to do a formatted read like that? Or do I need to use fstream, operator>>, and nested if statements?</p>