首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::basic_streambuf::sgetc

int_type sgetc();

?

?

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

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

参数

%280%29

返回值

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

二次

代码语言:javascript
复制
#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";
}

二次

产出:

二次

代码语言:javascript
复制
sgetc() returned 'H'
peek() returned 'H'
get() returned 'H'

二次

另见

sbumpc

reads one character from the input sequence and advances the sequence (public member function)

snextc

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

代码语言:txt
复制
 ? cppreference.com

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

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com