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.
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.
相关文章推荐
- printf('%08x',number)
- error: Error: String types not allowed (at 'layout_width' with value 'match_parent')
- warning incompatible implicit declaration of built-in function 'printf'
- pb中关于转义符'~'的用法
- Linux中单引号(''),双引号("")与反单引号(``)的用法与区别
- error C2065: 'FILE' 'fopen' 'fscanf' 'printf' 'fclose' 'scanf' : undeclared identifier
- 总结一下SQL语句中引号(')、quotedstr()、('')、format()在SQL语句中的用法
- printf 'Hello world'!
- 【iOS错误笔记】'CADbugPrintf.h'file not found
- linux之printf '%s\t %s\t %s\t %s\t %s\t \n' $(cat printf.txt)
- MATLAB中feval、class、'function_handle'、isa、strcmp的用法
- DedeCMS {dede:field name='array' /}的用法
- error C3163: '_vsnprintf': attributes inconsistent with previous declaration
- input type=hidden name='x'的用法总结
- python __name__=='__main__'用法
- C printf() 详解——printf('%08x',number);
- jquery $.expr[':'] 用法体会
- C语言:模拟实现printf,要求功能:print("ccc\ts!",'b','i','t',"welcome to you");
- Imagemagick + vs2008 的error C3163: '_vsnprintf': attributes inconsistent with previous declaration 编译错误
- ORA-02194: event specification syntax error 231 (minor error 286) near 'CONTEXTFOREVER'