I first read the file in binary, when I read the end of file, the file is closed, visual stdio 2013 error pointer over the border.
FILE *fp;
fp = fopen("stu_manage.txt", "ab+");
fseek(fp,0L,SEEK_END);
long last = ftell(fp) / length;
long i = 0L;
rewind(fp);
struct student *node=(struct student*)malloc(sizeof(struct student));
for (; i < last; i++)
{
if (fread(&node[i], length, 1, fp) != 1)
{
printf("read conpletely");
break;
}
}
if (fp!=NULL)
fclose(fp);
When I put here the pointer change into global variables, this error is solved, the array in some degree equivalent to the pointer here could not run I feel unable to understand.