|
马上加入,结交更多好友,共享更多资料,让你轻松玩转电力研学社区!
您需要 登录 才可以下载或查看,没有账号?立即加入
×
我现在在用c语言将数据从文件里读入数据出现了一些问题,希望能给予指正。
% t# `) |$ a) a( |/ i7 M>谢谢!2 t# c& {- a( J7 u1 w6 F
>文件date1里的数据是:1,2" {7 C4 _8 \9 L+ I8 [+ v( B' Q6 t
> 3.2,4
& @ D" i2 y9 ~2 x> 1.1,2,4
( O! g% U0 e* C% t& ^> 5,3,4.3
# ~& m7 P9 ~" B5 f0 Z2 Y6 R% s>#include<stdio.h>
% D4 ]: G! ^/ K; m' `& L8 w' l>void main()
. W5 C' ^( T' [" f>{6 R- Q+ d! N5 h3 B
>FILE *in,*out;. o8 |) A6 D. {0 s4 t
>float a[2][2],b[2][3];. A% o% s b" E
>int i;' n) `% d: Q$ M# c a$ O
>clrscr();7 w$ @8 C: s. r X% V6 M# N7 E
>if((in=fopen("date1.txt","r"))==NULL)
1 ^$ \! B" D4 s' ?& d8 ?3 j>{printf("cannot open this file\n");
( O5 \2 I* a% a p u>exit(0);}; S/ a6 Z' C1 c: E& ]) }
>if((out=fopen("result.txt","w"))==NULL); F# t+ S* J% ^% O7 v; }
>{printf("cannot open this file\n");
: J3 i; _1 v9 D>exit(0);}
; I% j- s1 H6 B2 p s+ i! Q% C! m; y>rewind(in);( d8 o4 u) `- {1 }# Z
>for(i=0;i<2;i++)
. C* [; ?. ]2 M' |& Z9 }>{fscanf(in,"%f,%f",&a[i][0],&a[i][1]);; L! O7 M! E/ j3 f ?, L, T
>printf("%f,%f",a[i][0],a[i][1]);' Z: ?8 j u3 h+ E3 C
>fprintf(out,"%f,%f,",a[i][0],a[i][1]);}3 ?8 D: x* f( O7 N" j/ v7 \; T0 u
>for(i=0;i<2;i++)
1 V) _! e' m/ W>{fscanf(in,"%f,%f,%f",&b[i][0],&b[i][1],&b[i][2]);
% H" y3 I" M' N/ ]>printf("%f,%f,%f",b[i][0],b[i][1],b[i][2]);/ N3 J( a8 U2 p7 E
>fprintf(out,"%f,%f,%f",b[i][0],b[i][1],b[i][2]);}1 u! E0 Q: c% w! `& ?& u+ ?+ E, \
>}
$ f" S3 _8 ]7 X, a>运行后出现 scanf : floating point formats not linked
2 l0 k8 Y5 x3 o0 Q# {, N# T>Abnormal program termination H* A& ~7 W3 w
& z- b2 v% g% f- G* W, G请问哪位高手能指点一下。实在是感激不尽。 |