std::uppercase, std::nouppercase
来自cppreference.com
| 在标头 <ios> 定义
|
||
| |
(1) | |
| |
(2) | |
启用浮点和十六进制整数输出中大写字符的使用。在输入时无效果。
1) 如同用调用
str.setf(std::ios_base::uppercase) 启用流 str 中的 uppercase 标志。2) 如同用调用
str.unsetf(std::ios_base::uppercase) 禁用流 str 中的 uppercase 标志。这是一个 I/O 操纵符,可用如 out << std::uppercase 的表达式对任何 std::basic_ostream 类型的 out 或用如 in >> std::uppercase 的表达式对任何 std::basic_istream 类型的 in 调用。
参数
| str | - | 到 I/O 流的引用 |
返回值
str(到操纵后的流的引用)。
示例
运行此代码
#include <iostream>
int main()
{
std::cout << std::hex << std::showbase
<< "0x2a with uppercase: " << std::uppercase << 0x2a << '\n'
<< "0x2a with nouppercase: " << std::nouppercase << 0x2a << '\n'
<< "1e-10 with uppercase: " << std::uppercase << 1e-10 << '\n'
<< "1e-10 with nouppercase: " << std::nouppercase << 1e-10 << '\n';
}
输出:
0x2a with uppercase: 0X2A
0x2a with nouppercase: 0x2a
1e-10 with uppercase: 1E-10
1e-10 with nouppercase: 1e-10
参阅
| 清除指定的 ios_base 标志 (函数) | |
| 设置指定的 ios_base 标志 (函数) |