struct banker *p2,*p1;
int i,j;
p2=head;
while(p2->next!=NULL)
{
p2=p2->next;
}
p1=p2->next;
j=p2->accounts+1;
p1=(struct banker *)malloc(LEN);
p1->accounts=j;
printf("input your name:");
scanf("%s",p1->name);
do{printf("\ninput your password:");
scanf("%d",&p1->password);
printf("\ninput your password again:");
scanf("%d",&i);
if(i!=p1->password)
printf("input your password erorr");
else
printf("creat password succeed");
}while(i!=p1->password);
printf("input your money:");
scanf("%f",&p1->money);
p2->next=p1;
p1->next=NULL;
printf("opening an account is succeed");
大家看看,我这个函数的作用是给一个链表的结尾再添个节点,但每次P1开辟空间的地址都是一样的,那怎么办?
[此贴子已经被作者于2007-10-23 18:46:39编辑过]