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

std::ends

Defined in header <ostream>

?

?

template< class CharT, class Traits > std::basic_ostream<CharT, Traits>& ends( std::basic_ostream<CharT, Traits>& os );

?

?

将空字符插入输出序列。os好像通过打电话os.put(CharT())...

这是一个只有输出的I/O操作程序,可以用如下表达式调用它out << std::ends对任何out类型std::basic_ostream...

注记

此机械手通常与std::ostrstream,当关联的输出缓冲区需要以空结尾作为C字符串处理时。

不像std::endl,这个机械手不会冲洗溪流。

参数

os

-

reference to output stream

返回值

os%28在插入空字符%29后引用流。

二次

代码语言:javascript
复制
#include <cstdio>
#include <strstream>
int main()
{
    std::ostrstream oss;
    oss << "Sample text: " << 42 << std::ends;
    std::printf("%s\n", oss.str());
    oss.freeze(false); // enable memory deallocation
}

二次

产出:

二次

代码语言:javascript
复制
Sample text: 42

二次

另见

ostrstream (deprecated)

implements character array output operations (class)

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

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

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com