请问各位朋友,我最近在编关于文件的c语言时,总是出现打开错误,这有一个例子,能帮我指点指点吗?谢谢了。。。#include<stdio.h>
#include<stdio.h>#include<stdlib.h>
void main()
{
int a[2],c,i;
FILE *sp,*sb;
char filename[10],filename2[10];
printf("please input the filename:(limit in ten data)\n");
scanf("%s",filename);
if((sp=fopen(filename,"r"))==NULL)
{
printf("open fail!\n");
exit(0);
}
for(i=0;i<2;i++)
fread(sp,sizeof(int),1,a[i]);
c=a[1]+a[0];
printf("%d",c);
if((sb=fopen(filename,"w"))==NULL)
{
printf("open fail!\n");
exit(0);
}
printf("input the write filename:\n");
scanf("%s",filename2);
fwrite(c,sizeof(int),1,sb);
printf("over!\n");
fclose(sp);
fclose(sb);
}