basic_istream::unget

將最近讀取的字元至資料流。

basic_istream<Elem, Tr>& unget( );

傳回值

資料流 (*this)。

備註

未格式化的輸入函式。 資料流放回上一個項目,如有可能,,就像是藉由呼叫 rdbuf - >sungetc。如果 rdbuf 為 null 指標,則為,如果 sungetc 對的呼叫會傳回 traits_type::eof,函式會 setstate(badbit)。不論是哪種情況,則會傳回 *this

如需 unget 方式的資訊可能會失敗,請參閱 basic_streambuf::sungetc

範例

// 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
  abc
型別" abc ":abc abc

需求

標題: <istream>

命名空間: std

請參閱

參考

basic_istream Class

iostream 程式設計

iostreams 慣例