c语言while退出无限循环,请教:为什么我用while(!feof(fp))时会出现无限循环????...
該樓層疑似違規已被系統折疊?隱藏此樓查看此樓
#include
#include
#include
#define LEN sizeof(struct bookl)
struct bookl
{
long num;
char?? name[20];
float price;
char people[20];
char??? prass[20];
int?? yes;
struct bookl *next;
};
void main()??? /*圖書查詢*/
{
struct bookl *bookment;
bookment=(struct bookl *)malloc(LEN);
char name[20];
int i;
FILE *fp;
printf("請輸入書名:\n");
scanf("%s",name);
printf("\n");
fp=fopen("E:\\課程設計\\met.txt","r");
if(fp==NULL)
{
printf("error\n");
return ;
}
else
{
while(!feof(fp))
{
printf("編號??? 書名??? 價格???? 出版社??? 借閱人?? 是否借出 \n ");
fread(&bookment->num,sizeof(int),1,fp);
fread(bookment->name,20,1,fp);
fread(bookment->prass,20,1,fp);
fread(bookment->people,20,1,fp);
fread(&bookment->price,sizeof(float),1,fp);
fread(&bookment->yes,sizeof(int),1,fp);
if(strcmp(bookment->name,name)==0)
{
printf("%-6ld%8s",bookment->num,bookment->name);
printf("%8f%8s",bookment->price,bookment->prass);
printf("%8s%6d",bookment->people,bookment->yes);
}
else
printf("查無此書,請重新選擇!\n");
fclose(fp);
}
}
總結
以上是生活随笔為你收集整理的c语言while退出无限循环,请教:为什么我用while(!feof(fp))时会出现无限循环????...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 数学建模c语言仿真软件,数学建模十五大经
- 下一篇: c语言4x4矩形转置,最快的转置4x4字