Udostępnij za pośrednictwem


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

Reference

basic_streambuf Class

iostream Programming

iostreams Conventions

Other Resources

basic_streambuf Members