I'm looking to format a double or long double for currency in C. I would like to place a dollar sign at the beginning, a negative if needed, commas iterating every third digit before decimal, and a dot immediately before decimal. So far, I have been printing numbers like so:
printf("Please enter an amount: $%.2Lf\n", money);
Which returns something like
Please enter an amount: $123456789.00
Numbers should look like this...
$123,456,789.00
$1,234.56
$123.45
I need it to work with any number. It would help if answers were actual code because I am relatively new at coding (freshman in college), but I know that might seem like the easy way out, so if anyone would like explaining it to me and walking me through I would greatly appreciate that too. This question was asked by someone before me on this site, but I need some serious help.
Thanks!