Number WITH appropriate comma's
I've just finished coding up a little with names and points:
Code:
Big Al 176
Charlie 1,850
Skittles 4,004
All went well, UNTIL I wanted to print out the integers WITH right justification AND comma's. :(
Since the numbers were "picked" out of several other string fields in each record, I put them into a string - so far, no comma's.
Then I had to change them into a number, so I used atoi to do that. So far, so good.
Finished my calculations with the numbers, and a new number is loaded into that string array, using sprintf(string, ...). Still, no comma's!
Now it's time to print it all out, but printf doesn't have a "print it with comma's" format specifier.
So NOW the fun begins :D
I got something put together that adds the padding and prints the comma's OK, but I'm wondering what would be a "standard" way to handle this?
Please, don't say "google", because I've googled this till the cows came home, already.
Thanks in advance. Oddly, my books make no mention of doing this. It's like nobody ever needed it, or something!