命名空间
变体
操作

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

来自 cppreference.cn
< 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 中移除)
从输入序列中读取一个字符并前进序列
(公共成员函数) [编辑]
前进输入序列,然后读取一个字符,但不再次前进
(公共成员函数) [编辑]