//从文件中读取
void outData(struct node * phead)
{
struct node * pfind=phead;
pfind=(struct node*) malloc(sizeof(struct node));
struct node * pnew=NULL;
FILE *fp=NULL;
fp=fopen("data.txt","r");
if(fp==NULL)
{
printf("文件读取失败\n");
return;
}
while(!feof(fp))
{
pnew=(struct node*) malloc(sizeof(struct node));
fscanf(fp,"%d%s%d%s%s",&pnew->data.no,pnew->data.name,&pnew->data.phone,pnew->data.home,pnew->data.email);
pnew->pnext=NULL;
pfind->pnext=pnew;
pfind=pfind->pnext;
}
fclose(fp);
}
//遍历节点
void shouNode(struct node * phead)
{
struct node * pfind=phead->pnext;
while(pfind!=NULL)
{
printf("☆★\n");
printf("编号:%d\t姓名:%s\t电话:%d\t住址:%s\t邮箱:%s\t\n",pfind->data.no,pfind->data.name,pfind->data.phone,pfind->data.home,pfind->data.email);
printf("☆★\n");
pfind=pfind->pnext;
}
}