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 257 views
1 answer 308 views
1 answer 236 views
1 answer 223 views
1 answer 211 views
1 answer 241 views
...