How do I align a number like this in C?

后端 未结 11 718
清歌不尽
清歌不尽 2020-12-04 12:13

I need to align a series of numbers in C with printf() like this example:

-------1
-------5
------50
-----100
----1000

Of

11条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-04 12:54

    Try converting to a string and then use "%4.4s" as the format specifier. This makes it a fixed width format.

提交回复
热议问题