C语言文件问题,很急

来源:百度知道 编辑:UC知道 时间:2024/06/03 10:53:02
详细代码在我这,先发一个函数:
void Find(Link l)
{

int sel; int num;
FILE *fp;
char finddata[20];
Node *p;

window(10,5,75,21);
textcolor(5+BLINK);
textbackground(15);
clrscr();
fp=fopen("file3.c","rb+");
if(fp==NULL)
{
printf("can't read the file!");
return;
}
fread(&l,sizeof(Node),1,fp);
if(!l->next)
{
printf("\n =====>Tips:no book imformation!\n");
return;
}
printf("\n =====>1find the book by number\n =====>2find the book by name\n");
scanf("%d",&sel);
if(sel==1)
{
printf(" input the book number you want to find:");
scanf("%s",finddata);
p=Search(l,finddata,"num");
if(p)
{
printf("\t\t\t\t the find rescourd:\n&qu

结点中的指针域存入文件是没有意义的,它只是你本次运行程序时各结点在本进程所占用的内存空间中的偏移地址,下次再运行程序时,从文件中读出来时已经失效了.
读文件时必须每读一个数据,就重新分配一个新的空间来放数据,不能直接使用读出来的指针成员的值.

沙发!