读取txt数据有误差,请指点!
txt文件内容:8 5 6
1 9 3
6 4 8
#include<stdio.h>
#include<stdlib.h>
int main()
{
FILE *fp;
int a[2],b[2],c[2];
int i,j,k,m;
fp=fopen("F:\\C\\3d.txt","r");
if((fp=fopen("F:\\C\\3d.txt","r"))==NULL)
{
printf("cannot open this file\n");
exit(0);
}
for(i=0,j=0,k=0;i<=2;i++,j++,k++)
fscanf(fp,"%u%u%u",&a[i],&b[j],&c[k]);
for(m=0;m<=2;m++)
printf("%d",a[m]);
for(m=0;m<=2;m++)
printf("%d",b[m]);
for(m=0;m<=2;m++)
printf("%d",c[m]);
}
运行结果是:416894638,a[0]和b[0]数据不对,其他数据都没问题???程序有什么问题,速就解!