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;
}
輸入:basic_streambuf_sgetctxt.
testing
Output
t
t
需求
標題: <streambuf>
命名空間: std