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 348 views
1 answer 137 views
1 answer 136 views
1 answer 121 views
1 answer 139 views
2 answers 147 views
1 answer 125 views
...