名前空間
変種
操作

std::basic_streambuf<CharT,Traits>::sgetc

提供: cppreference.com
< cpp‎ | io‎ | basic streambuf
 
 
 
 
int_type sgetc();

入力シーケンスから1文字読み込みます。

入力シーケンスの読み込み位置が利用可能でなければ underflow() を返します。 そうでなければ Traits::to_int_type(*gptr()) を返します。

目次

[編集]引数

(なし)

[編集]戻り値

get ポインタの指す文字の値。

[編集]

#include <iostream>#include <sstream>   int main(){std::stringstream stream("Hello, world");std::cout<<"sgetc() returned '"<<(char)stream.rdbuf()->sgetc()<<"'\n";std::cout<<"peek() returned '"<<(char)stream.peek()<<"'\n";std::cout<<"get() returned '"<<(char)stream.get()<<"'\n";}

出力:

sgetc() returned 'H' peek() returned 'H' get() returned 'H'

[編集]関連項目

入力シーケンスから文字をひとつ読み込み、シーケンスを進めます
(パブリックメンバ関数)[edit]
入力シーケンスを進めて、その後、進めずに文字をひとつ読み込みます
(パブリックメンバ関数)[edit]
close