cin stream position
<p>I am counting the number of non-whitespace characters in the standard input stream (cin) using in.get(). For every character which is not a whitespace character, I increment a counter.</p>

<p>After I'm done counting, I'd like to go back and read the characters. in is a parameter of type std::istream&amp; in (cin in this case).</p>

<p>Here's what I am trying:</p>

<pre><code>std::streampos sp = in.tellg();

while(in)
{
    char c = in.peek();

    if(isspace(c))
        break;

    ++str.mSize;
    in.get();
}

in.seekg(sp);
</code></pre>

<p>The value of sp is -1 indicating failure. Why?</p>
