example5_monetary_formatting.cpp

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#include <iostream>
#include <iomanip>
#include <locale>

int main() {
    std::locale::global(std::locale("en_US.UTF-8"));
    std::cout.imbue(std::locale());

    long double price = 1234567.89;

    std::cout << "Default monetary output:" << std::endl;
    std::cout << std::showbase << std::put_money(price) << std::endl;

    std::cout << "International monetary output:" << std::endl;
    std::cout << std::showbase << std::put_money(price, true) << std::endl;

    return 0;
}
Back to iomanip