sprintf(tmp,"%.2lf",ave);
sscanf(tmp,"%lf",&ave);
ave中为要操作的浮点数。
tmp 为一字符数组。
浮点数转换示例
本文介绍了如何使用sprintf和sscanf函数将浮点数转换为字符串再转回浮点数的过程。具体步骤包括:首先利用sprintf函数将浮点数转换为字符串存储在字符数组tmp中,然后通过sscanf函数从该字符串中读取浮点数。
sprintf(tmp,"%.2lf",ave);
sscanf(tmp,"%lf",&ave);
ave中为要操作的浮点数。
tmp 为一字符数组。
2万+
2359
1万+

被折叠的 条评论
为什么被折叠?