|
马上加入,结交更多好友,共享更多资料,让你轻松玩转电力研学社区!
您需要 登录 才可以下载或查看,没有账号?立即加入
×
我现在在用c语言将数据从文件里读入数据出现了一些问题,希望能给予指正。
* x* n8 B+ q+ B# N>谢谢!
) y& ?4 f# `( M+ P% d) A! B>文件date1里的数据是:1,2
: w/ l+ a4 Y" y0 M> 3.2,4# E; o& v- I: ~0 q1 @
> 1.1,2,4 a4 J" U, t$ b
> 5,3,4.3" D) g+ T) N! o0 f
>#include<stdio.h>2 z7 ~: W$ I$ K! k# t
>void main()) ?9 C. N! T4 U) L
>{
' M) c: P& u, R/ t; p4 w4 s( v>FILE *in,*out;2 R2 a% J! P9 n4 Q
>float a[2][2],b[2][3];+ M3 z$ }5 ]1 J
>int i;1 b* M( A; ~/ }% d
>clrscr();
( T; _( h, g6 D0 `4 d5 Z1 G>if((in=fopen("date1.txt","r"))==NULL)9 E9 F% x. T/ E7 F. k% v
>{printf("cannot open this file\n");
, A$ O' @& H7 l>exit(0);}' g+ T: X' [0 t4 s. y* d
>if((out=fopen("result.txt","w"))==NULL)
0 {6 p1 x8 [* G! J R>{printf("cannot open this file\n");" o8 j; P' e$ t+ C
>exit(0);}
% \. A; ^5 n3 j- s- C>rewind(in);
2 A# Q1 x0 K' A7 \# ]4 K>for(i=0;i<2;i++)
4 k# F2 u' Q, a5 h; i>{fscanf(in,"%f,%f",&a[i][0],&a[i][1]);0 P* L) l$ k( ]7 b( ^5 H; f7 Y* \
>printf("%f,%f",a[i][0],a[i][1]);# R8 J8 I; i4 G- ]! t, I
>fprintf(out,"%f,%f,",a[i][0],a[i][1]);}6 w# z2 x, ~) o% V* z) `9 R
>for(i=0;i<2;i++)
9 _) ? a' O) {; M' K5 s% C! l3 m. d>{fscanf(in,"%f,%f,%f",&b[i][0],&b[i][1],&b[i][2]); m$ d. Z3 D1 t9 N0 x
>printf("%f,%f,%f",b[i][0],b[i][1],b[i][2]);
- h4 X$ E8 H# S' ]3 j( H) n3 |* H5 c>fprintf(out,"%f,%f,%f",b[i][0],b[i][1],b[i][2]);}
- m& C1 q# `8 i! {( s0 F' `>}
3 n+ w0 d1 M' z>运行后出现 scanf : floating point formats not linked2 A' M |0 a; D; P
>Abnormal program termination. ] G# c; Z9 p
" e% {3 ^1 I( N2 d2 Z请问哪位高手能指点一下。实在是感激不尽。 |