다음을 통해 공유


basic_istream::peek

Returns the next character to be read.

int_type peek( );

반환 값

The next character that will be read.

설명

The unformatted input function extracts an element, if possible, as if by returning rdbuf ->sgetc. Otherwise, it returns 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

FakePre-67311050b43941c4b85c048462a31b9a-6cf7fdd77816409ca1d26ea4ec81fae4

요구 사항

Header: <istream>

네임스페이스: std

참고 항목

참조

basic_istream 클래스

iostream 프로그래밍

iostreams 규칙