printf函数的一点问题
这个代码为什么会输出mor呢,这个输出格式不是一般用在浮点数的吗?
[code=C/C++][/code]
char *g="morning";
printf("%.3s",g);
[解决办法]
printf HELP [.prec]How Output Precision Is Affected
.nn characters or n decimal places are printed.
If the output value has more than n characters, the output might be truncated or rounded. (Whether this happens depends on the type character.)
printf本身应有的功能,只是用的较少而已