다음을 통해 공유


basic_istream::putback

Puts a specified character into the stream.

basic_istream<Elem, Tr>& putback(
    char_type _Ch
);

매개 변수

  • _Ch
    A character to put back into the stream.

반환 값

The stream (*this).

설명

The unformatted input function puts back _Ch, if possible, as if by calling rdbuf->sputbackc. If rdbuf is a null pointer, or if the call to sputbackc returns traits_type::eof, the function calls setstate(badbit). In any case, it returns *this.

예제

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

int main( ) 
{
   char c[10], c2, c3;

   c2 = cin.get( );
   c3 = cin.get( );
   cin.putback( c2 );
   cin.getline( &c[0], 9 );
   cout << c << endl;
}
  

요구 사항

Header: <istream>

네임스페이스: std

참고 항목

참조

basic_istream 클래스

iostream 프로그래밍

iostreams 규칙