#include <iostream>
#include <locale>
int main() {
std::locale::global(std::locale("en_US.UTF-8"));
// 使用當(dāng)前本地化信息輸出日期時(shí)間
std::cout.imbue(std::locale(""));
std::time_t now = std::time(nullptr);
std::cout << std::put_time(std::localtime(&now), "%c") << std::endl;
return 0;
}
#include <iostream>
#include <locale>
int main() {
double num = 1234567.89;
// 使用當(dāng)前本地化信息格式化數(shù)字
std::cout.imbue(std::locale(""));
std::cout << std::fixed << std::put_money(num) << std::endl;
return 0;
}
#include <iostream>
#include <locale>
int main() {
double price = 50.5;
// 使用當(dāng)前本地化信息輸出貨幣符號(hào)
std::cout.imbue(std::locale(""));
std::cout << std::showbase << std::put_money(price) << std::endl;
return 0;
}