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 323 views
1 answer 258 views
1 answer 310 views
1 answer 238 views
1 answer 225 views
1 answer 213 views
1 answer 241 views
...