How to format a thousand separator in C with FreeBSD? I obtain the code from one of the answers here How can I format currency with commas in C? and it is working in my Ubuntu Linux system but not in my FreeBSD 11.4 and 14-CURRENT systems.
#include <stdio.h>
#include <locale.h>
int main(void)
{
setlocale(LC_NUMERIC, "");
printf("$%'.2Lf\n", 123456789.00L);
printf("$%'.2Lf\n", 1234.56L);
printf("$%'.2Lf\n", 123.45L);
return 0;
}
The
printfmanpage(3) says:so, it uses the locale separator.
You can do something like that:
then compile like this:
which will output: