<locale> localization of the standard C library affects formatted I / O operations with its character conversion rules and decimal point symbol set in the numeric formatting settings.
printf("Locale is: %s\n", setlocale(LC_ALL, NULL));
cout << doubleToString(3.14)<<endl;
setlocale(LC_ALL, "");
printf("Locale is: %s\n", setlocale(LC_ALL, NULL));
cout << doubleToString(3.14) << endl;
printf("Locale is: %c\n", localeconv()->thousands_sep);
printf("Decimal separator is: %s\n", localeconv()->decimal_point);
Result:
Locale is: C
3.140000
Locale is: French_France.1252
3,140000
Decimal separator is: ,
++, ++ <locale>, . , , C ++:
cout << 3.14<<" "<<endl;
cout.imbue(locale(""));
cout << 3.14 << " "<<1000000<< endl;
:
:
static std::string const& getDoubleFormat() { return "%f"; }
. , "%f", const char[3]. , , string const char* . , !
.