求大神帮忙看下程序,才学C语言~不知道什么原因错!!
#include<stdio.h>#include<stdlib.h>#include<string.h>#define line 30char buffer[30];struct stud{ char *s[line]; char num;}st1;void main(){ FILE *fp; st1.num=0; if((fp=fopen("Lab1test.DAT","r"))==NULL) { printf("1文件不存在!\n"); exit(0); } char bf[line]; while(!feof(fp)) { fgets(bf,line,fp); st1.s[st1.num]=bf;//每个数组指针指向对应文件行的数据 st1.num++; } fclose(fp); gets(buffer); int n=atoi(buffer);//获取打印的行数n printf("%s\n",st1.s[n-1]);//打印出文件中第n行数据}