标题:怎样才能使每次在调用函数中函数内开辟的空间地址不同
取消只看楼主
hxjtiger
Rank: 1
等 级:新手上路
帖 子:33
专家分:0
注 册:2007-10-9
 问题点数:0 回复次数:2 
怎样才能使每次在调用函数中函数内开辟的空间地址不同

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编辑过]

搜索更多相关主题的帖子: 函数 password 空间 printf 
2007-10-23 18:43
hxjtiger
Rank: 1
等 级:新手上路
帖 子:33
专家分:0
注 册:2007-10-9
得分:0 
我9点半回来看看大家的意见,上课去了

嘿嘿,呵呵,哈哈,困难不在是困难!!!
2007-10-23 18:49
hxjtiger
Rank: 1
等 级:新手上路
帖 子:33
专家分:0
注 册:2007-10-9
得分:0 

我的意思是我申请的地址是我链表中已经占用了的地址,一申请就把原来链表中某个节点的内容改变了。



嘿嘿,呵呵,哈哈,困难不在是困难!!!
2007-10-24 07:06



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-180165-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.863577 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved