title: sscanf behaviour / return value
body: <p>I'm a novice learning C and trying to understand the following code from an online lecture. It scans a string for an integer; if characters are encountered, the sscanf fails.</p>
  
  <pre><code>int n; char c;
  if (sscanf(string, " %d %c", &amp;n, &amp;c) == 1)
      //return the integer
  
  else
      // fail
  </code></pre>
  
  <p>I've read the the man pages for sscanf and am still confused about checking the return value and why this code works. They state that "These functions return the number of input items assigned".</p>
  
  <p>If sscanf encounters characters only, it writes them to &amp;c...but in that case &amp;n won't have been written to. In this case, I would have thought that the return value of sscanf would still be 1?</p>