|
马上加入,结交更多好友,共享更多资料,让你轻松玩转电力研学社区!
您需要 登录 才可以下载或查看,没有账号?立即加入
×
我现在在用c语言将数据从文件里读入数据出现了一些问题,希望能给予指正。
6 m8 J/ i: d4 }>谢谢!
1 ?' O, v7 z" J) c>文件date1里的数据是:1,2' W& n+ @2 q C/ W9 Z
> 3.2,45 K" M, |7 d2 ~3 d+ C( n
> 1.1,2,4( v2 a% } R s6 P0 q
> 5,3,4.3
0 r s! }6 M" U) ~/ x>#include<stdio.h>. d6 |% A- h4 Y0 a( Z1 b1 J; C
>void main()+ L! A4 y1 q; `5 m7 U" X
>{$ ]5 _6 n; G( Q+ x% r7 H
>FILE *in,*out;
) t Z5 u; V; Q \>float a[2][2],b[2][3];
9 E( m+ j3 O: D/ o( @/ j5 U' y>int i;
6 v& h* E# z8 U, B- h" ?; R# M2 g>clrscr();6 s$ Q2 G+ C/ V" ^& N5 ]
>if((in=fopen("date1.txt","r"))==NULL)
+ r9 F* c5 B4 x9 p0 z0 x: @>{printf("cannot open this file\n");/ Z+ {& F* Z/ Z# D6 o6 \ t
>exit(0);}
0 u& d6 {& P$ g. W' [( M>if((out=fopen("result.txt","w"))==NULL)
9 w- }& P. a, z2 j3 m0 g3 V' M>{printf("cannot open this file\n");! E+ C$ r! I4 G9 E
>exit(0);}$ l$ p; {3 F& f; {
>rewind(in);' F i8 e1 m' ]5 G* R) L
>for(i=0;i<2;i++)
6 r* W: s% i( G8 b* R0 D>{fscanf(in,"%f,%f",&a[i][0],&a[i][1]);6 O& D k! I: \3 n
>printf("%f,%f",a[i][0],a[i][1]);; F: q7 N* D: R
>fprintf(out,"%f,%f,",a[i][0],a[i][1]);}0 Z2 y: t- U0 D8 q6 X
>for(i=0;i<2;i++)
) m7 C+ K9 t- g, k! }1 ~8 G>{fscanf(in,"%f,%f,%f",&b[i][0],&b[i][1],&b[i][2]);" }: e7 ~" f- s8 q# W
>printf("%f,%f,%f",b[i][0],b[i][1],b[i][2]);
+ g: x6 C2 I' Z* T) f3 I>fprintf(out,"%f,%f,%f",b[i][0],b[i][1],b[i][2]);}
* j7 |! r9 T9 W( x ?* T>}
% X$ y1 H ~ ^! B>运行后出现 scanf : floating point formats not linked
( ^% v4 M5 i, x>Abnormal program termination
. U3 Q- Q, ^( l' J' ?* F1 m6 v/ E0 K2 q- X
请问哪位高手能指点一下。实在是感激不尽。 |