各位大神,我编写的代码不知为什么陷入了死循环,不停显示,求指点
程序代码:
#include<stdio.h> #include<stdlib.h> #define LEN 40 int main() { FILE*fp; char name[LEN]; char ch; long locate; while(gets(name)&&name[0]=='\0') puts("Pleas input again"); if((fp=fopen(name,"r"))==NULL) exit(0); while(scanf("%ld",&locate)==1) { fseek(fp,locate,SEEK_SET); while((ch=getc(fp))!='\n') putc(ch,stdout); } fclose(fp); return 0; }