次の方法で共有


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

59xe2ztd.collapse_all(ja-jp,VS.110).gif出力

t
t

必要条件

ヘッダー: <streambuf>

名前空間: std

参照

関連項目

basic_streambuf Class

入出力ストリームのプログラミング

入出力ストリームの規則