#include<iostream.h>
#include<iomanip.h>
#include<string.h>
struct data
{
int year; int month; int day;
};
struct friends
{
char name[12];
char sex;
char tel[12];
date birthday;
friends* next;
};
int a;
struct friends* create()
{
struct friends *head,*p1,*p2;
a=0;
p1=p2=new friends;
cout<<"Input my friends'name,with'#'to end;"<<endl;
cin>>p1->name;
cout<<"Continue to input my friends'sex(F/M),tel and birthday:"<<endl;
cin>>p1->sex;
cin>>p1->tel;
cin>>p1->birthday.year>>p1->birthday.month>>p1->birthday.day;
head=NULL;
while(strcmp(p1->name,"#")!=0)
{
a++;
if(a==1)
head=p1;
else
p2->next=p1;
p2=p1;
p1=new friends;
cout<<"Input my friends'name,with'#'to end;"<<endl;
cin>>p1->name;
if(strcmp(p1->name,"#")!=0)
{
cout<<"Continue to input my friends'sex(F/M),tel and birthday:"<<endl;
cin>>p1->sex;
cin>>p1->tel;
cin>>p1->birthday.year>>p1->birthday.month>>p1->birthday.day;
}
}
p2->next=NULL;
return head;
}
void print(struct friends* head)
{
struct friends* p;
p=head;
cout<<setw(11)<<"name"<<setw(5)<<"sex"<<setw(12)<<"telNO."
<<setw(16)<<"birthday"<<endl;
while(p!=NULL)
{
cout<<setw(11)<<p->name<<setw(4)<<p->sex<<setw(16)<<p->tel<<" ";
cout<<setw(5)<<p->birthday.year;
cout<<setw(3)<<p->birthday.month<<" ";
cout<<setw(2)<<p->birthday.day<<endl;
p=p->next;
}
}
void main()
{
friends *s;
s=create();
print(s);
}
以上程序我用VC6.0编译的时候出现21项错误,小弟忘各位给指点下错在那里了