formatting - C - Printing formatted output of money -


in program print out table, 1 of columns has money listed. want print out money values neatly , right justified, below:

  $9.00   $8.00  $19.20 $200.90 

i can right justify numbers so

while(condition) {    printf("$%5.2f\n", number); } 

but method $ isn't positioned want it, , output more like:

$    9.00 $    8.00 $   19.20 $  200.90 

can formatting want printf?

you can auxiliary string:

while(condition) {    char str[10] = {};    sprintf(str, "$%.2f", number);    printf("%8s\n", str); } 

Comments

Popular posts from this blog

iphone - Three second countdown in cocos2d -

hyperlink - how to do url routing in php -

c - Avoiding Extra Malloc in Linked List (node->next = NULL) -