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

std::basic_streambuf::sputn

std::streamsize sputn( const char_type* s, std::streamsize count );

(1)

?

protected: virtual std::streamsize xsputn( const char_type* s, std::streamsize count );

(2)

?

1%29次电话xsputn(s, count)最派生的类。

2%29写count指向其第一个元素的字符数组的输出序列的字符。s.这些字符的书写方式就好像是通过反复调用sputc().写作在任何一种情况下都会停止count字符被写入或调用sputc()会回来的Traits::eof()...

如果放置区域变成满的%28pptr() == epptr()%29,此函数可调用overflow(),或达到调用的效果。overflow()其他的,没有具体说明的,意思是。

参数

%280%29

返回值

成功写入的字符数。

二次

代码语言:javascript
复制
#include <iostream>
#include <sstream>
 
int main()
{
    std::ostringstream s1;
    std::streamsize sz = s1.rdbuf()->sputn("This is a test", 14);
    s1 << '\n';
    std::cout << "The call to sputn() returned " << sz << '\n'
              << "The output sequence contains " << s1.str();
 
    std::istringstream s2;
    sz = s2.rdbuf()->sputn("This is a test", 14);
    std::cout << "The call to sputn() on an input stream returned " << sz << '\n';
}

二次

产出:

二次

代码语言:javascript
复制
The call to sputn() returned 14
The output sequence contains This is a test
The call to sputn() on an input stream returned 0

二次

另见

sgetn

invokes xsgetn() (public member function)

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

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

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com