xprintf format string

说明:xprintf表示printf系列的函数。


The  format string is a character string, beginning and ending in its initial shift state, if any. 

The format string is composed of zero or more directives:


格式说明串主要包含两部分,普通字符转换说明符

1. ordinary characters (not %), which are copied unchanged to the output stream;

    普通字符直接输出

2. conversion specifications, each of which results in fetching  zero  or  more subsequent arguments.  

    Each conversion specification is introduced by the character %, and ends with a conversion specifier. 

     转换说明符形如%d,可能需要0个或多个后序参数

   

  "%  [flags ...]  [minimum field width] [precision]  [length modifier] conversion-specifications"

  • [flags ...]

    • #  加前缀,o->0, x->0x

    • 0  converted value is padded on the left with zeros rather than blanks.

    • -   The converted value is to be left adjusted on the field  boundary.

    • ' '  A blank should be left before a positive  number  (or empty string) produced by a signed conversion.

    • +  A  sign  (+  or -) should always be placed before a number produced by a signed conversion.

  • [minimum field width]

            如果结果位宽不足,则用空格填充;如果位宽超过限制也不会造成结果被截断,而是忽略位宽限制

  • [precision]    

    • 格式为.[num],如果只有小数点则取精度为0;负数忽略该限制;

    • This gives the minimum number of digits to appear for d, i, o, u, x, and X conversions

    • This gives the  number of digits to appear after the radix character for a, A, e, E, f, and F conversions

    • the maximum number of significant digits for g and G conversions

    • the maximum  number of characters to be printed from a string for s and S conversions.

  • [length modifier]

    • hh --> char

    • h   --> short int

    • l    --> long int

    • ll   --> long long int

    • L  --> long double

    • z  --> sizt_t

    • t   --> ptrdiff_t

  • conversion specifications (A  character that specifies the type of conversion to be applied. )

    • d,i : int --> signed decimal

    • o,u,x,X : unsigned int --> unsigned octal,hexadecimal

    • e,E: The double argument is  rounded  and  converted  in  the  style [-]d.ddde±dd

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值