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 213 views
1 answer 166 views
1 answer 221 views
1 answer 127 views
1 answer 138 views
1 answer 124 views
1 answer 142 views
...