So, you are trying to insert commas into the numbers, then print them?
Typically you need to imbue the stream with a locale that automatically does that for you.
For example, on Linux, my locale is en_US.UTF-8.
If I do:
const int x = 1000000;
std::cout << x << std::endl;
The nice thing about this is that it formats the number properly for whatever locale is appropriate for the user.
A German might see this:
$ LANG=de_DE.UTF-8 ./locale_test
Last edited on
That works fine on Linux, but locale support is typically broken on Windows. MinGW users must use STLPort or some other standard library to get C++ locale support of any kind.
The code works just fine with VS2010.