How to format a number with thousands separator (commas) in C++

1 Answer

0 votes
#include <iostream>
#include <locale>

int main() {
    int n = 49782521;

    std::cout.imbue(std::locale(""));
    std::cout << n;
}

  

  
/*
run:
  
49,782,521

*/

 



answered Dec 28, 2020 by avibootz

Related questions

1 answer 298 views
1 answer 258 views
1 answer 309 views
1 answer 237 views
1 answer 225 views
1 answer 212 views
1 answer 241 views
...