title: Using ifstream as fscanf
body: <p>Assume that I have an input as follows:</p>
  
  <pre><code>N (X_1,Y_1) (X_2,Y_2) .... (X_N, Y_N)
  </code></pre>
  
  <p>where N, X_i and Y_i are integers.</p>
  
  <p>An example:</p>
  
  <pre><code>2 (55,1) (521,7)
  </code></pre>
  
  <p>To read this, I can do something like this(assume all variables are defined, etc.):</p>
  
  <pre><code>fscanf(fin,"%d ",&amp;N);
  for (int i = 0; i &lt; N; i++)
     fscanf(fin,"(%d,%d) ", &amp;X[i], &amp;Y[i]);
  </code></pre>
  
  <p>The question is, how can I do this easily using ifstream. I can get string's, and then I can get rid of nondigits and using stringstream I can get two numbers but this seems a bit cumbersome. Is there an easier, more elegant way?</p>
  
  <p>Thanks</p>