| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 664 人关注过本帖
标题:怎样才能使每次在调用函数中函数内开辟的空间地址不同
取消只看楼主 加入收藏
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
快速回复:怎样才能使每次在调用函数中函数内开辟的空间地址不同
数据加载中...
 
   



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

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