다음을 통해 공유


basic_streambuf::sputbackc

Puts a char_type in the stream.

int_type sputbackc( 
   char_type _Ch 
);

매개 변수

  • _Ch
    The character.

반환 값

Returns the character or failure.

설명

If a putback position is available and _Ch compares equal to the character stored in that position, the member function decrements the next pointer for the input buffer and returns traits_type::to_int_type(_Ch). Otherwise, it returns pbackfail(_Ch).

예제

// basic_streambuf_sputbackc.cpp
// compile with: /EHsc
#include <iostream>
#include <fstream>

int main( )
{
    using namespace std;

    ifstream myfile("basic_streambuf_sputbackc.txt",
        ios::in);

    int i = myfile.rdbuf()->sbumpc();
    cout << (char)i << endl;
    int j = myfile.rdbuf()->sputbackc('z');
    if (j == 'z')
    {
        cout << "it worked" << endl;
    }
    i = myfile.rdbuf()->sgetc();
    cout << (char)i << endl;
}

Input: basic_streambuf_sputbackc.txt

testing

Output

t
it worked
z

요구 사항

Header: <streambuf>

네임스페이스: std

참고 항목

참조

basic_streambuf 클래스

iostream 프로그래밍

iostreams 규칙