std::basic_streambuf<CharT,Traits>::sgetc
From cppreference.com
< cpp | io | basic streambuf
| int_type sgetc(); |
||
入力シーケンスから1文字読み取ります。
入力シーケンスの読み取り位置が利用できない場合、underflow()を返します。それ以外の場合、Traits::to_int_type(*gptr())を返します。
目次 |
[編集] パラメータ
(なし)
[編集] 戻り値
get pointerが指す文字の値。
[編集] 例
このコードを実行
#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'
[編集] 関連項目
| (C++17 で削除) |
入力シーケンスから1文字を読み込み、シーケンスを進める (public member function) |
| 入力シーケンスを進め、その後、再度進めずに1文字を読み取る (public member function) |