std::ends
来自cppreference.com
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
在头文件 <ostream> 中定义
|
||
template< class CharT, class Traits > std::basic_ostream<charT,traits>& ends( std::basic_ostream<CharT, Traits>& os ); |
||
到输出序列中插入一个空字符
os
如果通过调用os.put(CharT()). 原文:
Inserts a null character into the output sequence
os
as if by calling os.put(CharT()). 这是一个只输出的I / O机械手,它可被称为用一个表达式如out << std::ends任何
out
类型std::basic_ostream原文:
This is an output-only I/O manipulator, it may be called with an expression such as out << std::ends for any
out
of type std::basic_ostream.目录 |
[编辑] 注释
该机械手std::ostrstream,通常用于关联的输出缓冲区需要以空值终止为C字符串处理.
原文:
This manipulator is typically used with std::ostrstream, when the associated output buffer needs to be null-terminated to be processed as a C string.
std::endl不同,该机械手不刷新流.
原文:
Unlike std::endl, this manipulator does not flush the stream.
[编辑] 参数
os | - | 引用到输出流
|
[编辑] 返回值
os
(参考插入空字符后的流)原文:
os
(reference to the stream after insertion of the null character)[编辑] 示例
#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 }
输出:
Sample text: 42
[编辑] 另请参阅
(已弃用) |
实现字符数组输出操作 原文: implements character array output operations (类) |