std::ends
来自cppreference.com
输入/输出库
输入/输出操纵符
浮点格式化 | |||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||
整数格式化 | |||||||||||||||||||||||||||||||
布尔格式化 | |||||||||||||||||||||||||||||||
域宽与填充控制 | |||||||||||||||||||||||||||||||
其他格式化 | |||||||||||||||||||||||||||||||
空白符处理 | |||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||
输出冲入 | |||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
状态标志操纵 | |||||||||||||||||||||||||||||||
时间与金钱 I/O | |||||||||||||||||||||||||||||||
带引号操纵符 | |||||||||||||||||||||||||||||||
(C++14)
|
在标头
<ostream>
定义
|
||
template< class CharT, class Traits >
std::basic_ostream<CharT, Traits>& ends( std::basic_ostream<CharT, Traits>& os ); |
||
如同以调用 os.put(CharT()) 插入空字符到输出序列中
os
。
这是仅输出的 I/O 操纵符,可以用如 out << std::ends 的表达式对任何 std::basic_ostream
类型的 out
调用。
注意
此操纵符典型地为 std::ostrstream 在关联输出缓冲区需要为空终止,以作为 C 字符串处理时使用。
不同于 std::endl ,此操纵符不冲入流。
参数
os | - | 到输出流的引用 |
返回值
os
(到插入空字符后的流的引用)
示例
运行此代码
#include <cstdio> #include <strstream> int main() { std::ostrstream oss; oss << "Sample text: " << 42 << std::ends; std::printf("%s\n", oss.str()); oss.freeze(false); // 启用内存解分配 }
输出:
Sample text: 42
参阅
(C++98
中弃用)
|
实现字符数组输出操作 (类) |