I execute the following code:

#include <iostream> #include <sstream> int main() { std::stringstream stream; stream<<123456789<<std::endl; std::cout<<stream.str()<<std::endl; return 0; } 

Screen output: 123,456,789. I would like to receive: 123456789

I’m wondering how to make sure that when writing a number to stream no commas are added.

  • one
    I tried in vindoz under visuals 2008 and in linux under gcc 4.9. No commas. - Hermann Zheboldov
  • Is the option to convert to a numeric value (long i = atol (stream.c_str ());) not suitable? - maxmail

1 answer 1

I think this is a localization effect.

Try calling setlocale(LC_ALL, "C") at the beginning of the program (see man setlocale ).