命名空间
变体
操作

std::uppercase, std::nouppercase

来自 cppreference.cn
< cpp‎ | io‎ | manip
 
 
 
输入/输出 操纵符
浮点数格式化
整数格式化
布尔格式化
字段宽度和填充控制
其他格式化
uppercasenouppercase
空白处理
输出刷新
(C++20)  

状态标志操作
时间和货币 I/O
(C++11)
(C++11)
(C++11)
(C++11)
带引号的操纵符
(C++14)
 
定义于头文件 <ios>
std::ios_base& uppercase( std::ios_base& str );
(1)
std::ios_base& nouppercase( std::ios_base& str );
(2)

在浮点数和十六进制整数输出中启用大写字符的使用。对输入没有影响。

1) 在流 str 中启用 uppercase 标志,如同调用 str.setf(std::ios_base::uppercase) 一样。
2) 在流 str 中禁用 uppercase 标志,如同调用 str.unsetf(std::ios_base::uppercase) 一样。

这是一个 I/O 操纵符,可以与表达式一起调用,例如 out << std::uppercase,对于任何类型为 std::basic_ostreamout,或者与表达式一起调用,例如 in >> std::uppercase,对于任何类型为 std::basic_istreamin

目录

[编辑] 参数

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 标志
(函数) [编辑]