What is the difference between %0.2lf and %.2lf as printf placeholders?

前端 未结 4 1287
耶瑟儿~
耶瑟儿~ 2021-02-08 07:15

I am aware that putting any number of 0\'s before the width of the placeholder implements zero-padding. For example, printf(\"%02d\", 6); prints

4条回答
  •  你的背包
    2021-02-08 07:50


    %3.2f //(print as a floating point at least 3 wide and a precision of 2)

    %0.2lf //(print as a floating point at least 0 wide and a precision of 2)

    %.2lf //(print as a floating point at least 0(default) wide and a precision of 2)

提交回复
热议问题