int myread()
{ int i=0,j=0;
FILE *FP=NULL;
FP= fopen("C:\\Win-TC\projects\\shuju.txt", "r");
if(FP==NULL)
{ printf("Can not open the file.\n");
getch();
exit(0);
}
for(j=0;j<4;j++)
{ for(i=0;i<2; i++)
fscanf(FP,"%d", &data1.a[j][i]);
}
fclose(FP);
return 0;
}
这个子程序为什么一直打不开文本文件?
调用为:myread();
不对吗?
屏幕显示为
Can not open the file.
吗?
是的,不知道为什么啊?有的时候不能调用,有的时候可以但是屏幕显示为
Can not open the file。
if(FP==NULL)
{ printf("Can not open the file.\n");
getch();
exit(0);
}
判断里没有return
在后面加上结果也是一样啊,你说在那个位置加啊?
追答主程序的代码发来看看
本回答被提问者采纳