C printf问题
在CSDN上看到的下面的语句是用来打印buffer的前NumberOfBytesRead个字符
发觉连这个printf都没有完全学懂……
看不明白的语法
int NumberOfBytesRead=2;
charbuffer[]="adsf";
printf("%.*s\n",NumberOfBytesRead,buffer);
手头借了本M$P的 ANSI and STANDARD C Programmer's Reference 好像说得挺详细
不过是E文 ,先发帖,再慢慢看 * The width is not specified in the format string, it is specified by an integer value preceding the argument thas has to be formatted.
.precision meaning
.number for d, i, o, u, x, X types: precision specifies the minimum number of decimal digits to be printed. If the value to be printed is shorter than this number the result is padded with blanks. The value is never truncated even if the result is larger.(if nothing specified default is 1).
页:
[1]