名稱空間
變體
操作

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

來自 cppreference.com
< cpp‎ | io‎ | basic streambuf
 
 
 
 
int_type sgetc();

從輸入序列讀取一個字元。

若輸入序列讀位置不可用,則返回 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'

[編輯] 參閱

(C++17 中移除)
從輸入序列中讀取一個字元並推進序列
(公開成員函式) [編輯]
推進輸入序列,然後讀取一個字元而不再次推進
(公開成員函式) [編輯]