您的位置:首页 > 其它

printf Width Specification('*'的用法)

2011-01-05 16:57 162 查看
今天注意到了printf 里面 ‘*’的用法,查了一下MSDN:

printf Width Specification

The second optional field of the format specification is the width
specification. The width argument is a nonnegative decimal integer
controlling the minimum number of characters printed. If the number of
characters in the output value is less than the specified width, blanks are
added to the left or the right of the values — depending on whether the – flag
(for left alignment) is specified — until the minimum width is reached. If
width is prefixed with 0, zeros are added until the minimum width is
reached (not useful for left-aligned numbers).

The width specification never causes a value to be truncated. If the number
of characters in the output value is greater than the specified width, or if
width is not given, all characters of the value are printed (subject to
the precision
specification).

If the width specification is an asterisk (*), an int argument
from the argument list supplies the value. The width argument must
precede the value being formatted in the argument list. A nonexistent or small
field width does not cause the truncation of a field; if the result of a
conversion is wider than the field width, the field expands to contain the
conversion result.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐