首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

printf函数的一点有关问题

2012-03-12 
printf函数的一点问题这个代码为什么会输出mor呢,这个输出格式不是一般用在浮点数的吗?[codeC/C++][/code

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本身应有的功能,只是用的较少而已

热点排行
Bad Request.