在线文档教程
C++
输入/输出 | Input/output

std::basic_streambuf::sgetc

性病:基本[医]流光::sgetc

int_type sgetc(

从输入序列中读取一个字符。

如果输入序列读取位置不可用,则返回underflow().否则返回Traits::to_int_type(*gptr())...

参数

%280%29

返回值

对象所指向的字符的值。获取指针...

二次

#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'

二次

另见

sbumpcreads one character from the input sequence and advances the sequence (public member function)
snextcadvances the input sequence, then reads one character without advancing again (public member function)

© cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

http://en.cppreference.com/w/cpp/io/basic[医]Streambuf/sgetc