◐ Shell
clean mode source ↗

std::basic_streambuf<CharT,Traits>::sgetc - cppreference.com

提供: cppreference.com

<tbody> </tbody>

入力シーケンスから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'

関連項目