std::basic_istream<CharT,Traits>::unget

Makes the most recently extracted character available again.

# Declarations

basic_istream& unget();

# Return value

*this

# Example

#include <iostream>
#include <sstream>
 
int main()
{
    std::istringstream s1("Hello, world.");
    char c1 = s1.get();
    if (s1.unget())
    {
        char c2 = s1.get();
        std::cout << "Got: '" << c1 << "'. Got again: '" << c2 << "'.\n";
    }
}

# See also