Partager via


basic_istream::peek

Returns the next character to be read.

int_type peek( );

Return Value

The next character that will be read.

Remarks

The unformatted input function extracts an element, if possible, as if by returning rdbuf ->sgetc. Otherwise, it returns traits_type::eof.

Example

// 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

FakePre-827eacef85f94ca5a7689f44b9e70651-b38c6b9c1ee442149d8c7a1c3476afc0

Requirements

Header: <istream>

Namespace: std

See Also

Reference

basic_istream Class

iostream Programming

iostreams Conventions

Other Resources

basic_istream Members