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

来自cppreference.com
< cpp‎ | io‎ | basic streambuf
 
 
 
 
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 移除)
从输入序列读取一个字符并令序列前进
(公开成员函数)[编辑]
推进输入序列,然后读取一个字符而不再推进
(公开成员函数)[编辑]
close