程序没有错误却运行不了
程序代码:
#include <stdio.h> #include <stdlib.h> #define A 18 struct node { char book[18]; int number; char publish; char writer; char time; double p[18]; }stud[A]; int main() { int i,j; double t; FILE*fp; if ((fp = fopen("123.txt", "r+")) == NULL) { printf("cannot open file\n"); exit(0); } for (j=0;j<17;j++) for (i=0;i<17-j;i++) if (stud[i].p[i]>stud[i].p[i+1]) { t=stud[i].p[i];stud[i].p[i]=stud[i+1].p[i+1];stud[i+1].p[i+1]=t; } { fread(&stud[i], sizeof(struct node),1,fp); printf("%s %d %s %s %s %lf\n", stud[i].book,stud[i].number,stud[i].publish,stud[i].writer,stud[i].time,stud[i].p); } fclose(fp); return 0; }
运行不了,导致程序停止,有没有能解决的啊