using c++ on windows,
trying to set the locale to be used by the swprintf function.
i need to include the thousand separator with the number which is printed out.
i tried several options…
_wsetlocale(LC_NUMERIC, L""); //default locale
also..
_wsetlocale(LC_NUMERIC, L"english");
and of course..
swprintf(buf, L"%d", 3546);
i also tried to display the number as follows
auto locale = _get_current_locale();
_swprintf_l(buf, L"%d", locale, 3546);
i need to get the thousands separator, i.e 3,456
i also placed a breakpoint to see the value of the locale variable, it contains the lconv struct with the thousands separator correctly set to , … however, swprintf is ignoring it.
Tested on Linux
Try with that :
Example :
You are missing the
'use%'dand not%dStill working with wchar
An other example :
Windows
Well today I did test on Windows (with mingw) and this is not implemented…
Please read this link, which provides a solution http://c-faq.com/stdio/commaprint.html