While learning more about standard library, I came across put_money. My code:
std::cout.imbue(std::locale("en_US.UTF-8"));
std::cout << std::left << std::showbase << std::setfill('*')
<< "flt: " << std::setw(15) << -9.87 << '\n'
<< "hex: " << std::setw(15) << 41 << '\n'
<< " $: " << std::setw(15) << std::put_money(367, false) << '\n'
<< "usd: " << std::setw(15) << std::put_money(367, true) << '\n'
<< "usd: " << std::setw(15)
<< std::setfill(' ') << std::put_money(367, false) << '\n';
But while compiling this code I received an error stating:
C:\Users\tbhar\Documents\C++ codes>cd "c:\Users\tbhar\Documents\C++ codes\" && g++ codetester.cpp -Wall -Wextra -o codetester && "c:\Users\tbhar\Documents\C++ codes\"codetester
terminate called after throwing an instance of 'std::runtime_error'
what(): locale::facet::_S_create_c_locale name not valid
Similar error is occuring while using functions like:
std::put_money
, std::get_time
, and std::put_time
.
I don't know why I am receiving this error.