该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
getch();
return(0);
}
p=stu->head;
clrscr();
printf("\n\nThere are all %d datas in this DateBase.\n\n",stu->length);
printf("%-15s","index");
printf("%-15s","Name");
printf("%-15s","Phone");
printf("%-15s\n","postcost");
i=1;
do
{
printf("%-15d",i++);
printf("%-15s",p->data.name);
printf("%-15s",p->data.phone);
printf("%-15s\n",p->data.postcost);
p=p->next;
j--;
}while(j!=0);
printf("\nPress any key to continue.");
getch();
}
Load (struct adLinklist *stu)
{
FILE *fp;
char fname[10];
struct dNode *temp;
printf("\nEnter the filename you want to load:");
gets(fname);
if((fp=fopen(fname,"rb"))==NULL)
{
printf("\nCan't Load the file.Please check the filename.");
getch();
return(0);
}
temp=(struct dNode*)malloc(sizeof(struct dNode));
fread(temp,sizeof(struct dNode),1,fp);
temp->prior=temp;
temp->next=temp;
stu->head=temp;
stu->rear=temp;
stu->length=1;
while(!feof(fp))
{
temp=(struct dNode*)malloc(sizeof(struct dNode));
fread(temp,sizeof(struct dNode),1,fp);
temp->prior=stu->rear;
temp->next=stu->head;
stu->rear->next=temp;
stu->rear=temp;
stu->head->prior=stu->rear;
stu->length++;
}
printf("\nLoad successful! Press any to continue.");
fclose(fp);
getch();
}
Save(struct adLinklist *stu)
{
struct dNode *temp1;
char fname[10];
FILE *fp1;
int i;
i=stu->length;
if(i==0)
{
printf("\nError! DateBase is empty! ENTER new data or LOAD DateBase from file.");
getch();
return(0);
}
printf("\nEnter the filename you want to save:");
gets(fname);
if((fp1=fopen(fname,"wb"))==NULL)
{
printf("Can't Save the file\n");
return(0);
}
temp1=stu->head;
while(i>0)
{
fwrite(temp1,sizeof(struct dNode),1,fp1);
temp1=temp1->next;
i--;
}
printf("Save succesfull.Press any key to continue.");
getch();
fclose(fp1);
}
Help()
{
clrscr();
printf("\n\n HELP About the Programme \n\n");
printf(" **************************************************\n");
printf(" * 1.ENTER a new data to current DateBase *\n");
printf(" * 2.DELETE a data from the current DateBase *\n");
printf(" * 3.SEARCH a data of the current DateBase *\n");
printf(" * 4.LIST all data of the current DateBase *\n");
printf(" * 5.SAVE the current database to HardDisk *\n");
printf(" * 6.LOAD a database from the HardDisk *\n");
printf(" * 7.EXIT the Programe *\n");
printf(" * 8.HELP about this programme *\n");
printf(" **************************************************\n\n");
printf(" CopyRight @ AUST DCST 02-6 WuTao\n");
printf(" All Rights Reseved\n");
printf(" 2004.12.28\n\n\n");