title: How to use sscanf in loops?
body: <p>Is there a good way to loop over a string with <code>sscanf</code>?</p>
  
  <p>Let's say I have a string that looks like this:</p>
  
  <pre><code>char line[] = "100 185 400 11 1000";
  </code></pre>
  
  <p>and I'd like to print the sum.  What I'd really like to write is this:</p>
  
  <pre><code>int n, sum = 0;
  while (1 == sscanf(line, " %d", &amp;n)) {
    sum += n;
    line += &lt;number of bytes consumed by sscanf&gt;
  }
  </code></pre>
  
  <p>but there's no clean way to get that information out of <code>sscanf</code>.  If it returned the number of bytes consumed, that'd be useful.  In cases like this, one can just use <code>strtok</code>, but it'd be nice to be able to write something similar to what you can do from <code>stdin</code>:</p>
  
  <pre><code>int n, sum = 0;
  while (1 == scanf(" %d", &amp;n)) {
    sum += n;
    // stdin is transparently advanced by scanf call
  }
  </code></pre>
  
  <p>Is there a simple solution I'm forgetting?</p>