다음을 통해 공유


basic_streambuf::sgetc

Returns current element without changing position in the stream.

int_type sgetc( );

반환 값

The current element.

설명

If a read position is available, the member function returns traits_type::to_int_type(*gptr). Otherwise, it returns underflow.

예제

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

int main( ) 
{
   using namespace std;
   ifstream myfile( "basic_streambuf_sgetc.txt", ios::in );

   char i = myfile.rdbuf( )->sgetc( );
   cout << i << endl;
   i = myfile.rdbuf( )->sgetc( );
   cout << i << endl;
}

Input: basic_streambuf_sgetc.txt

testing

Output

t
t

요구 사항

Header: <streambuf>

네임스페이스: std

참고 항목

참조

basic_streambuf 클래스

iostream 프로그래밍

iostreams 규칙