回复 2楼 TonyDeng
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
float DoubleToFloat(double h);
void main(void)
{
printf("%.2f\n", DoubleToFloat(123456.3263));
_getch();
}
float DoubleToFloat(double h)
{
float ret = 0.0;
char buffer[20];
sprintf(buffer, "%.2f", h);
if (strlen(buffer) <= 9)
{
sscanf(buffer, "%f", &ret);
}
return ret;
}
不太懂,因为才刚学,不过还是谢谢喽,呵呵呵
还有,那个要去掉-s才行