fcvt

fcvt,函式名,功能是把一個浮點數轉換為字元串。

解釋

函式名: 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;
clrscr();
value = 9.876;
string = ecvt(value, ndig, &dec, &sign);
printf("string = %s dec = %d \
sign = %d\n", string, dec, sign);
value = -123.45;
ndig= 15;
string = ecvt(value,ndig,&dec,&sign);
printf("string = %s dec = %d sign = %d\n",
string, dec, sign);
value = 0.6789e5; /* scientific
notation */
ndig = 5;
string = ecvt(value,ndig,&dec,&sign);
printf("string = %s dec = %d\
sign = %d\n", string, dec, sign);
return 0;
}

相關詞條

相關搜尋

熱門詞條

聯絡我們