std::basic_streambuf::sputn, std::basic_streambuf::xsputn
来自cppreference.com
< cpp | io | basic streambuf
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
std::streamsize sputn( const char_type* s, std::streamsize count ); |
(1) | |
protected: virtual std::streamsize xsputn( const char_type* s, std::streamsize count ); |
(2) | |
最派生类调用
2) xsputn(s, count)
.原文:
Calls
xsputn(s, count)
of the most derived class.count
字符写入到输出序列中的字符数组,该数组的第一个元素是指向s
。如果重复调用sputc()
被写入的字符。写作停止count
字符时,无论是书面还是会返回调用sputc()
traits::eof().如果把已满(pptr()==epptr()),此功能可致电
overflow()
,或达到的效果overflow()
调用一些其他的,未指定意思原文:
If the put area becomes full (pptr()==epptr()), this function may call
overflow()
, or achieve the effect of calling overflow()
by some other, unspecified, means.目录 |
[编辑] 参数
(无)
[编辑] 返回值
成功的字符数写的
原文:
The number of characters successfully written.
[编辑] 示例
#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'; }
输出:
The call to sputn() returned 14 The output sequence contains This is a test The call to sputn() on an input stream returned 0
[编辑] 另请参阅
调用xsgetn() (公共成员函数) |