#include<stdio.h>
int main()
{
FILE *fpt;
char c[100];
printf("请输入目标文件");
gets(c);
fpt=fopen(c,"r");
if(fpt==NULL)
{
printf("不能打开文件");
return -1;
}
int n,i;
fscanf(fpt,"%d",&n);
int a[n],b;
fgetc(fpt);
while(!feof(fpt))
{
fscanf(fpt,"%d",&b);
a[i]=b;
fgetc(fpt);
i++;
}
for(i=0;i<n;i++)
printf("a[%d]=%d\n",i,a[i]);
fclose(fpt);
return 0;
}
调试到a[i]=b这一行总是显示segmentation fault,还有如果改成fscanf(fpt,"%d",&a[i])也会显示segmentation fault这是怎么回事啊,有人解答一下吗。