| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 508 人关注过本帖
标题:feof()问题啊!急速等待解决啊!
只看楼主 加入收藏
wei495715356
Rank: 1
等 级:新手上路
帖 子:57
专家分:0
注 册:2006-10-15
收藏
 问题点数:0 回复次数:0 
feof()问题啊!急速等待解决啊!

这里的bookname()里的feof()总是死循环
请求各位大哥帮我解决啊!
跪求啊!
#include "stdio.h"
#include "stdlib.h"
#include "conio.h"
#include "string.h"
#define TRUE 1
/***********结构*************/
typedef struct books
{
char sort[5]; /*中图法分类号*/
unsigned long id; /*图书编号*/
char name[12]; /*书名*/
char auther[36]; /*作者(考虑多个作者情况)*/
double books_concern[100]; /*出版社*/
long date; /*出版日期*/
unsigned long ibsn; /*ISBN*/
int edtions; /*版次*/
int price; /*定价*/
int number; /*馆藏数*/
int loan; /*借阅数*/
struct books *next; /*指针*/
}book;
typedef struct lendman
{
char name[36]; /* 借书人名字 */
double units[100]; /* 借书人所在单位 */
unsigned long id; /* 借书证号 */
char bookname[36]; /* 所借图书书书名 */
unsigned bookid; /*图书编号*/
long indate; /* 借书日期 */
long redate; /*还书日期*/
int m; /* 逾期 */
int n; /* 逾期罚款额 */
struct lendman *next; /*指针*/
}lender;
typedef struct stock
{
char name[12]; /*书名*/
char auther[36]; /*作者*/
char indate[10]; /*采购日期*/
int inmunber; /*采购数量*/
int oneprice; /*采购单价*/
unsigned price; /*采购金额*/
unsigned invoiceid; /*发票号码*/
char id[10]; /*图4E66编号*/
struct stock *next;
}stock;

void mainmenu();
void bookmenu(void);
void membermenu(void);
void stockmenu(void);
void chiose1();
void books_input();
void books_demand(void);
void books_insert(void);
void books_delete(void);
void bookadd();
void bookname();
void members_input();
void members_demand();
void members_insert();
void members_delete();
void members_borrow();
void members_return();
main()
{

mainmenu();
}
/*主菜单*/
void mainmenu()
{
int n;
clrscr();
printf("\n\n\n\n\n\n");
printf(" |**********Books Information Management System**********| \n");
printf(" |-------------------------------------------------------| \n");
printf(" | Please input option(0~3): | \n");
printf(" | 1---Books | \n");
printf(" | 2---Members | \n");
printf(" | 3---Stocks | \n");
printf(" | 0---Quit | \n");
printf(" |-------------------------------------------------------| \n");
scanf("%d",&n);
chiose1(n);
}
/*主菜单选择*/
void chiose1(int n)
{
switch(n)
{ case 1: bookmenu(); break;
case 2: membermenu(); break;
case 3: stockmenu(); break;
case 0: return;
default: printf("Input error.Please again.");
}
}
/*子菜单图书*/
void bookmenu()
{
int m;
clrscr();
printf("\n\n\n\n\n");
printf(" |********** Books Menu **********| \n");
printf(" |-------------------------------------------------------| \n");
printf(" | Please input OPtion(0~4): | \n");
printf(" | 1---Books input | \n");
printf(" | 2---Books demand | \n");
printf(" | 3---Books insert | \n");
printf(" | 4---Books delete | \n");
printf(" | 0---Return mainmenu | \n");
printf(" |-------------------------------------------------------| \n");

scanf("%d",&m);
switch(m)
{ case 1: books_input(); break;
case 2: books_demand(); break;
case 3: books_insert(); break;
case 4: books_delete(); break;
case 0: mainmenu();
default : printf("Input error.Please again.");
}
}
void books_input()
{
bookadd();
}
void books_demand()
{
bookname();
}
/*图书的插入*/
void books_insert()
{
bookadd();
}
/*图书的删除*/
void books_delete()
{
}
void bookadd()
{
FILE *fp; /* 定义指向文件的指针 */
book consultbook;
fp=fopen("books.txt","rb");/*以读方式打开文件*/
if(fp==NULL)
fp=fopen("books.txt","wb");/*以写方式打开文件*/
else {
fclose(fp);
fp=fopen("books.txt","ab");/*以追加方式打开文件*/
}
printf("please input two letter:");
scanf("%s",consultbook.sort);
printf("please input ID nummber:");
scanf("%d",&consultbook.id);
printf("please input book name:");
scanf("%s",consultbook.name);
printf("please input auther:");
scanf("%s",consultbook.auther);
printf("please input book concern :");
scanf("%s",consultbook.books_concern);
printf("please input output date:");
scanf("%d",&consultbook.date);
printf("please input ibsn:");
scanf("%d",&consultbook.ibsn);
printf("please input edtions:");
scanf("%d",&consultbook.edtions);
printf("please input price:");
scanf("%d",&consultbook.price);
printf("please input book number:");
scanf("%*c%d",&consultbook.number);
consultbook.next=NULL;
fwrite(&consultbook,sizeof(book),1,fp);
fclose(fp);
clrscr();
bookmenu();
}
void bookname()
{
FILE *fp;
book consultbook;
char bookname[12];/*书名*/
int i=2,flag=0;
printf("Input the book name:");
scanf("%s",bookname);
fp=fopen("books.txt","rb");
if(fp==NULL)
{
clrscr();
printf("Error!");
/*fclose(fp);*/
exit(-1);
}

while(!feof(fp))
{

fread(&consultbook,sizeof(book),1,fp);

if(strcmp(consultbook.name,bookname)==0)
{
clrscr();
i = feof(fp);
printf ("The feop(fp)is %d\n\n",i);
printf("This book %s information as follow:\n",consultbook.name);
printf("this book's sort is %s\n",consultbook.sort);
printf("this book's ID is %d\n",consultbook.id);
printf("this book's auther is %s\n",consultbook.auther);
printf("this book's concern is %s\n",consultbook.books_concern);
printf("this book's output date is %d\n",consultbook.date);
printf("this book's ibsn is %d\n",consultbook.ibsn);
printf("this book's edtions is %d\n",consultbook.edtions);
printf("this book's price is %d\n",consultbook.price);
printf("this book's book number is %d\n",consultbook.number );
flag=1;
}
}
if(flag==0)
{
clrscr();
printf("NO found this book");
}
fclose(fp);

}

搜索更多相关主题的帖子: feof 
2007-03-25 14:07
快速回复:feof()问题啊!急速等待解决啊!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.028851 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved