通讯录C++链表实现

来源:百度知道 编辑:UC知道 时间:2024/05/10 07:08:25
struct person
{
char number[20];
char name[20];
char sex[4];
char birthday[20];
char address[20];
char like[20];
char Special[20];
char telephone[8];
person * next;
};

person*p1
fstream inifile.getline(p1->number,50);
问题到底怎么解决啊?

#include"stdio.h"
#include"malloc.h"
#include "string.h"
#include"stdlib.h"
#include"iostream.h"

#define LEN sizeof(struct person)
struct person
{
char number[20];
char name[20];
char sex[20];
char birthday[20];
char degree[20];
char work[20];
char phone[20];
char adress[20];
struct person *next;
};
struct person *head=NULL;
FILE *fp;

void creat()
{ struct person *p,*q;
head=q=p=(struct person *)malloc(sizeof(struct person));

if((fp=fopen("person.dat","rb"))!=NULL)
{ while(fread(p,sizeof(struct person),1,fp)==1)
{ q=p;
p=(struct person *)malloc(sizeof(struct person));
q->next=p;
}
q->next=NULL;}
else
head=NULL;

}