std::uppercase / std::nouppercase

std::uppercase / std::nouppercase (대문자 조작자)

부동소수점·16진수 정수 출력에서 대문자 사용을 켜거나 끄는 조작자예요. 입력에는 영향이 없어요.

출처: cppreference

본문

<ios> 헤더에 정의돼 있어요.

// (1)
std::ios_base& uppercase( std::ios_base& str );

// (2)
std::ios_base& nouppercase( std::ios_base& str );

부동소수점·16진수 정수 출력에서 대문자 사용을 켜거나 끕니다. 입력에는 영향이 없어요.

    1. str.setf(std::ios_base::uppercase)처럼 uppercase 플래그를 켜요.
    1. str.unsetf(std::ios_base::uppercase)처럼 uppercase 플래그를 꺼요.

I/O 조작자라 out << std::uppercase처럼 쓸 수 있어요.

예제

#include <iostream>

int main()
{
    std::cout << std::hex << std::uppercase << 255 << ' '   // "FF"
              << std::nouppercase << 255 << '\n';            // "ff"
}

더 알아보기 (Learn more)

cppreference