|
楼主 |
发表于 2004-5-8 17:34:32
|
显示全部楼层
<>函数名: fcvt
功 能: 把一个浮点数转换为字符串
用 法: char *fcvt(double value, int ndigit, int *decpt, int *sign);
程序例: <>#include <stdlib.h>
#include <stdio.h>
#include <conio.h> <>int main(void)
{
char *string;
double value;
int dec, sign;
int ndig = 10; <P> clrscr();
value = 9.876;
string = ecvt(value, ndig, &dec, &sign);
printf("string = %s dec = %d \
sign = %d\n", string, dec, sign); <P> value = -123.45;
ndig= 15;
string = ecvt(value,ndig,&dec,&sign);
printf("string = %s dec = %d sign = %d\n",
string, dec, sign);
<P> value = 0.6789e5; /* scientific
notation */
ndig = 5;
string = ecvt(value,ndig,&dec,&sign);
printf("string = %s dec = %d\
sign = %d\n", string, dec, sign); <P> return 0;
}
</P> |
|