What is `scanf` supposed to do with incomplete exponent-part? : <p>Take for example <code>rc = scanf("%f", &amp;flt);</code> with the input <code>42ex</code>. An implementation of <code>scanf</code> would read <code>42e</code> thinking it would encounter a digit or sign after that and realize first when reading <code>x</code> that it didn't get that. Should it at this point push back both <code>x</code> and <code>e</code>? Or should it only push back the <code>x</code>.</p>

<p>The reason I ask is that GNU's libc will on a subsequent call to <code>gets</code> return <code>ex</code> indicating they've pushed back both <code>x</code> and <code>e</code>, but the standard says:</p>

<blockquote>
  <p>An input item is read from the stream, unless the speciﬁcation includes an n speciﬁer. An input item is deﬁned as the longest sequence of input characters which does not exceed any speciﬁed ﬁeld width and which is, or is a preﬁx of, a matching input sequence[245] The ﬁrst character, if any, after the input item remains unread. If the length of the input item is zero, the execution of the directive fails; this condition is a matching failure unless end-of-ﬁle, an encoding error, or a read error prevented input from the stream, in which case it is an input failure. </p>
</blockquote>

<p>I interpret this as since <code>42e</code> is a prefix of a matching input sequence (since for example <code>42e1</code> would be a matching input sequence), which should mean that it would consider <code>42e</code> as a input item that should be read leaving only <code>x</code> unread. That would also be more convenient to implement if the stream only supports single character push back.</p>
