I can do
locale loc(""); // use default locale
cout.imbue( loc );
cout << << "i: " << int(123456) << " f: " << float(3.14) << "\n";
and it will output:
i: 123.456 f: 3,14
on my system. (german windows)
I would like to avoid getting the thousands separator for ints — how can I do this?
(I just want the users default settings but without any thousands separator.)
(All I found is how to read the thousands separator using use_facet with the numpunct facet … but how do I change it?)
Just create and imbue your own numpunct facet:
If you have to create a specific output for another application to read, you may also want to override
virtual char_type numpunct::do_decimal_point() const;.If you want to use a specific locale as base, you can derive from the
_bynamefacets: