|
马上加入,结交更多好友,共享更多资料,让你轻松玩转电力研学社区!
您需要 登录 才可以下载或查看,没有账号?立即加入
×
我现在在用c语言将数据从文件里读入数据出现了一些问题,希望能给予指正。
) e7 q B7 e8 ~>谢谢!9 G; X1 C- |7 {; Y6 A& H
>文件date1里的数据是:1,2
1 k0 v/ q5 X H- @/ w1 }8 H0 Y> 3.2,4
2 e! F# Q9 E/ i+ M5 N; g) Z0 g2 A( P> 1.1,2,4* x9 `- O% U8 D! T8 A
> 5,3,4.3
8 ^% t3 u4 s- X. {5 }/ F5 p>#include<stdio.h>
! k4 e1 \. e) [: h9 X5 f>void main()/ z( A/ p; q/ i- c0 ^; w
>{5 a I) z# f7 V
>FILE *in,*out;
2 m! u+ j8 I Q) h) r>float a[2][2],b[2][3];
. D. W3 o8 l. u! b0 {6 Q' _5 B3 Y>int i;% P. a* j4 U/ E6 c i
>clrscr();: n5 H9 C8 ]" u; F2 O d" M p8 K
>if((in=fopen("date1.txt","r"))==NULL)9 Y) `( b# S7 u7 m
>{printf("cannot open this file\n");
1 e. \) |9 c/ T( m2 H7 t>exit(0);}* {! l$ Z& f9 @+ K
>if((out=fopen("result.txt","w"))==NULL)
$ m* D2 _( v+ u8 F# m>{printf("cannot open this file\n");
: L2 w6 [& H5 W>exit(0);}
0 \1 P+ S$ A- L4 |& _ B3 [9 A>rewind(in);
/ _( L" l* J: {9 S/ A1 i0 F+ t>for(i=0;i<2;i++)2 x, q9 z9 o( k3 p3 o9 E
>{fscanf(in,"%f,%f",&a[i][0],&a[i][1]);
4 K8 c4 g% f6 r2 w& p>printf("%f,%f",a[i][0],a[i][1]);) D! e- c6 j& n) w, F# C1 }
>fprintf(out,"%f,%f,",a[i][0],a[i][1]);}8 ]) C% f8 S; _* h
>for(i=0;i<2;i++)
" a' f% G- Y4 @% f3 V>{fscanf(in,"%f,%f,%f",&b[i][0],&b[i][1],&b[i][2]);8 A9 u" p5 m. i' r
>printf("%f,%f,%f",b[i][0],b[i][1],b[i][2]);6 D" m$ L6 f; r
>fprintf(out,"%f,%f,%f",b[i][0],b[i][1],b[i][2]);}
- u) A ?5 F, s5 u& t$ x>}; s2 h0 m$ V* ]; @
>运行后出现 scanf : floating point formats not linked6 M- H. Q: z* D2 o9 w. `9 ^
>Abnormal program termination
' k$ R; [" U( {/ @9 T) V
2 |, `7 B! w) ^: Q请问哪位高手能指点一下。实在是感激不尽。 |