Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Puts the most recently read character back into the stream.
basic_istream<Elem, Tr>& unget( );
Return Value
The stream (*this).
Remarks
The unformatted input function puts back the previous element in the stream, if possible, as if by calling rdbuf ->sungetc. If rdbuf is a null pointer, or if the call to sungetc returns traits_type::eof, the function calls setstate(badbit). In any case, it returns *this.
For information on how unget might fail, see basic_streambuf::sungetc.
Example
// basic_istream_unget.cpp
// compile with: /EHsc
#include <iostream>
using namespace std;
int main( )
{
char c[10], c2;
cout << "Type 'abc': ";
c2 = cin.get( );
cin.unget( );
cin.getline( &c[0], 9 );
cout << c << endl;
}
abc
FakePre-25d057c745b74e46b07f99057ba1c25a-bb24812845e7448688c2f7c4a16753ae
Requirements
Header: <istream>
Namespace: std