|
streambuf::sputbackcpublic member function
int sputbackc ( char c ); Put character back The get pointer is moved back to point to the character right before its current position so the last character gotten, c, becomes available again as the character to be read at that position by the next input operation.During its operation, the function calls the protected virtual member function pbackfail either if the character c doesn't match gptr()[-1] or if the get pointer gptr points to the same position as the beginning pointer eback. When c does not match the character at that position, the default definition of pbackfail in streambuf will prepend c to be the character extracted at that position if possible, but derived classes may override this behavior. The member function sungetc behaves in a similar way but without taking any parameters. Parameters
Return ValueThe value of the character put back.If the get pointer is at the beginning of the input sequence or any other error occurs, the value returned is EOF (or traits::eof() for other traits). Example
This example gets characters form the standard input one by one. When the first numeric digit is found, sputback is called to restore the position in the stream to that digit in order to be extracted as part of a number using the extraction operator >>. Basic template member declaration( basic_streambuf<charT,traits> )
See also
|