std::put_money

std::put_money (통화 삽입 조작자)

통화 값을 문자 표현으로 변환해 출력하는 조작자예요. C++11부터 있어요.

출처: cppreference

본문

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

template< class MoneyT >
/*unspecified*/ put_money( const MoneyT& mon, bool intl = false );

out << put_money(mon, intl) 표현식에서, 현재 out에 적용된 로케일의 std::money_put 패싯이 지정하는 대로 통화 값 mon을 문자 표현으로 변환해요. out << put_money(mon, intl) 삽입 연산은 FormattedOutputFunction처럼 동작해요.

매개변수

  • monlong double 또는 std::basic_string인 통화 값.
  • intltrue면 국제 통화 문자열을 사용하고, 아니면 통화 기호를 사용해요.

반환값

out << put_money(mon, intl)out을 돌려주는 미지정 타입 객체.

예제

#include <iostream>
#include <iomanip>
#include <locale>

int main()
{
    std::cout.imbue(std::locale("en_US.UTF-8"));
    std::cout << std::put_money(1234567.89) << '\n';  // "$1,234,567.89"
}

더 알아보기 (Learn more)

cppreference