Evan wrote:
>> Actually I still think you should be only reading 2 characters from
>> the input stream. If you read 3, a subsequent read will be missing
>> the leading digit. I am too lazy to check now, but RTFM on
>> istream::get.
>
> get( buffer, count ) reads count-1 characters from the string, then
> tags on a terminating 0.
>
> "The three-argument s.get(p,n,term) reads at most n-1 characters into
> p[0]..p[n-2]. A call of get() will always place a 0 at the end of the
> characters (if any) it placed in p[], so p must point to an array of
> at least n characters." (3rd edition of Strostrup, p. 618-619)
>
> cin.read is available if you don't want the null termination added.
You're absolutely correct. I overcame my lazyness and looked it up in
the Standard. Lo and behold, count-1 characters are stored and the null
character is stuffed into the buffer. I must have confused it with the
'read' member. Rats!