basic_istream::peek

傳回要讀取的下一個字元。

int_type peek( );

傳回值

要讀取的下一個字元。

備註

未格式化的輸入函式擷取項目,如有可能,,則會傳回 rdbuf - >sgetc。否則,會傳回 traits_type::eof

範例

// basic_istream_peek.cpp
// compile with: /EHsc
#include <iostream>
using namespace std;

int main( ) 
{
   char c[10], c2;
   cout << "Type 'abcde': ";

   c2 = cin.peek( );
   cin.getline( &c[0], 9 );

   cout << c2 << " " << c << endl;
}
  abcde
  abcde
型別" abcde:abcde abcde

需求

標題: <istream>

命名空間: std

請參閱

參考

basic_istream Class

iostream 程式設計

iostreams 慣例