|
楼主 |
发表于 2004-5-8 17:41:03
|
显示全部楼层
<>函数名: gcvt
功 能: 把浮点数转换成字符串
用 法: char *gcvt(double value, int ndigit, char *buf);
程序例: <>#include <stdlib.h>
#include <stdio.h> <>int main(void)
{
char str[25];
double num;
int sig = 5; /* significant digits */ <P> /* a regular number */
num = 9.876;
gcvt(num, sig, str);
printf("string = %s\n", str); <P> /* a negative number */
num = -123.4567;
gcvt(num, sig, str);
printf("string = %s\n", str); <P> /* scientific notation */
num = 0.678e5;
gcvt(num, sig, str);
printf("string = %s\n", str); <P> return(0);
}
</P> |
|