次の方法で共有


basic_streambuf::sgetc

Returns current element without changing position in the stream.

int_type sgetc( );

Return Value

The current element.

Remarks

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

Example

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

Requirements

Header: <streambuf>

Namespace: std

See Also

Concepts

basic_streambuf Class

basic_streambuf Members

iostream Programming

iostreams Conventions