線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:759
推到 Plurk!
推到 Facebook!

建檔疑問

尚未結案
1111ricky
一般會員


發表:2
回覆:3
積分:1
註冊:2003-09-13

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-09-14 04:05:59 IP:61.230.xxx.xxx 未訂閱
請問為什麼下列程式所建立的txt檔內容是錯誤的 AnsiString str; FILE *fp; str="123.txt"; fp=fopen(str.c_str(),"w"); long double a=0.0005456444444444887; fprintf(fp,"%f\n",a);
1111ricky
一般會員


發表:2
回覆:3
積分:1
註冊:2003-09-13

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-09-14 04:11:20 IP:61.230.xxx.xxx 未訂閱
請問為什麼下列程式所建立的txt檔內容是錯誤的 AnsiString str; FILE *fp; str="123.txt"; fp=fopen(str.c_str(),"w"); long double a=0.0005456444444444887; fprintf(fp,"%f\n",a); fclose(fp);
gemi0305
版主


發表:81
回覆:564
積分:629
註冊:2003-05-11

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-09-14 12:58:04 IP:61.224.xxx.xxx 未訂閱
These modifiers determine how printf functions interpret the next input argument, arg[f].    Prefix        Format specifier        Type specified
F        p s                   A far pointer
N        n                  A near pointer
h        d i o u x X        A short int
l        d i o u x X        A long int
l        e E f g G                 A double
L        e E f g G                 A long double
L        d i o u x X        An __int64
h        c C        A single-byte character
l        c C        A Wide character
h        s S        A single-byte character string
l        s S        A Wide character string
These modifiers affect how all the printf functions interpret the
 data type of the corresponding input argument arg.    Both F and N reinterpret the input variable arg. Normally, the arg 
for a %p, %s, or %n conversion is a pointer of the default size for
 the memory model.    h, l, and L override the default size of the numeric data input 
arguments. Neither h nor l affects pointer (p,n) types.
 
這是BCB online的說明,另外 你的資料超出有效範圍了,會有部份資料無法存入, 可能要找個大一點的格式, 照上面的說明,可以試試: fprintf(fp,"%Lf\n",a); 或 fprintf(fp,"%Le\n",a); 這個會比較好 國泰平安 發表人 -
1111ricky
一般會員


發表:2
回覆:3
積分:1
註冊:2003-09-13

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-09-14 18:22:05 IP:61.230.xxx.xxx 未訂閱
非常感謝..您是我的救命恩人阿..
系統時間:2024-06-08 3:09:50
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!