std::showpos, std::noshowpos
浮点格式化 | |||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||
整数格式化 | |||||||||||||||||||||||||||||||
布尔格式化 | |||||||||||||||||||||||||||||||
域宽与填充控制 | |||||||||||||||||||||||||||||||
其他格式化 | |||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||
空白符处理 | |||||||||||||||||||||||||||||||
输出冲入 | |||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
状态标志操纵 | |||||||||||||||||||||||||||||||
时间与金钱 I/O | |||||||||||||||||||||||||||||||
带引号操纵符 | |||||||||||||||||||||||||||||||
(C++14)
|
在标头
<ios>
定义
|
||
std::ios_base&
showpos( std::ios_base&
str );
|
(1) | |
std::ios_base&
noshowpos( std::ios_base&
str );
|
(2) | |
启用或禁用非负数输出中的正号 '+' 的显示。在输入上无效果。
1) 如同用调用 str.setf(std::ios_base::showpos) 启用流
str
中的 showpos
标志
2) 如同用调用 str.unsetf(std::ios_base::showpos) 禁用流
str
中的 showpos
标志
这是一个 I/O 操纵符,可用如 out
<< std::showpos 的表达式对任何
std::basic_ostream
类型的 out
或用如 in >> std::showpos 的表达式对任何
std::basic_istream
类型的 in
调用。
参数
str | - | 到 I/O 流的引用 |
返回值
str
(到操纵后的流的引用)
示例
#include <iostream> int main() { std::cout << "showpos: " << std::showpos << 42 << ' ' << 3.14 << ' ' << 0 << '\n' << "noshowpos: " << std::noshowpos << 42 << ' ' << 3.14 << ' ' << 0 << '\n'; }
输出:
showpos: +42 +3.14 +0 noshowpos: 42 3.14 0
参阅
清除指定的 ios_base 标志 (函数) |
|
设置指定的 ios_base 标志 (函数) |