How to add comma to a number every 3 digits in C++

1 Answer

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

int main() {
    long n = 84940083567;
    
    std::cout.imbue(std::locale(""));

    std::cout << n;
}




/*
run:

84,940,083,567

*/

 



answered Nov 5, 2021 by avibootz

Related questions

3 answers 498 views
1 answer 232 views
1 answer 242 views
1 answer 206 views
1 answer 220 views
2 answers 257 views
1 answer 209 views
...