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

1 Answer

0 votes
#include <stdio.h>
#include <locale.h>

int main() {
    long double ld = 28153056843;
    
    setlocale(LC_NUMERIC, "");
    
    printf("%'Lf", ld);

    return 0;
}
  
  

  
/*
run:
  
28,153,056,843.000000

*/

 



answered Dec 28, 2020 by avibootz

Related questions

1 answer 232 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
...