basic_streambuf::sgetc

返回当前元素,而不用更改流中的位置。

int_type sgetc( );

返回值

当前元素。

备注

如果读取位置可用,成员函数返回 traits_type::to_int_type(*)。gptr 否则,返回。下溢

示例

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

Enter:basic_streambuf_sgetc.txt

testing

Output

t
t

要求

页眉: <streambuf>

命名空间: std

请参见

参考

basic_streambuf 类

iostream 编程

iostreams 约定