std::basic_streambuf<CharT,Traits>::sgetc
来自cppreference.com
< cpp | io | basic streambuf
输入/输出库
std::basic_streambuf
公开成员函数 | ||||
本地环境 | ||||
寻位 | ||||
获取区 | ||||
basic_streambuf::sgetc
|
||||
放置区 | ||||
回放 | ||||
受保护成员函数 | ||||
(C++11)
|
||||
(C++11)
|
||||
本地环境 | ||||
寻位 | ||||
获取区 | ||||
放置区 | ||||
回放 | ||||
int_type sgetc();
|
||
从输入序列读取一个字符。
若输入序列读位置不可用,则返回 underflow() 。否则返回 Traits::to_int_type(*gptr()) 。
参数
(无)
返回值
获得指针所指向的字符的值。
示例
运行此代码
#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 中移除)
|
从输入序列读取一个字符并令序列前进 (公开成员函数) |
令输入序列前进,读取一个字符而不再次前进 (公开成员函数) |