在C语言中调用子程序的格式是什么?

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;
}
这个子程序为什么一直打不开文本文件?

第1个回答  2011-05-24

#include <stdio.h>
#include <stdlib.h>
main()//主函数
{
int x,y;//定义整形
scanf("%d%d",&x,&y);
printf("两数之和=%d\n",x*y);
system("pause");
}
第2个回答  2011-05-25
会不会是你的main中调用的方法不对呢?追问

调用为: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

追问

在后面加上结果也是一样啊,你说在那个位置加啊?

追答

主程序的代码发来看看

本回答被提问者采纳
第3个回答  2011-05-24
直接函数名(参数);
相似回答