fork(2) download
  1. #include <iostream>
  2. #include <sstream>
  3. #include <locale>
  4.  
  5. struct dotted : std::numpunct<char> {
  6. char do_thousands_sep() const { return '.'; } // separate with dots
  7. std::string do_grouping() const { return "\3"; } // groups of 3 digits
  8. static void imbue(std::ostream &os) {
  9. os.imbue(std::locale(os.getloc(), new dotted));
  10. }
  11. };
  12.  
  13. int main()
  14. {
  15. int Value = 12345678;
  16. std::stringstream ss;
  17. dotted::imbue(ss);
  18. ss << Value;
  19. std::cout << ss.str() << '\n';
  20. }
Success #stdin #stdout 0s 3276KB
stdin
Standard input is empty
stdout
12.345.678