c语言地址传递的发生条件,.........问下地址传递的问题。。。

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

cb497ebd0b4583ee5f0e6c4212f72c13.gif

struct friend //结构体

{

char name[20];

char phonenumber[20];

char address[200];

char character[200];

struct friend *next;

};

void arrangenumber() //主程序中的一个函数

{

struct friend *test,*p,*q;

int count;

char tmp_name[20];

char tmp_phonenumber[20];

char tmp_address[200];

char tmp_character[200];

head=test;

if(n>1)

{

for(count=1;count

{

q=test;

p=test->next;

while(p->next!=NULL)

{

if(strcmp(q->name,p->name)>0)

{

tmp_name=q->name; //为什么不能这样传递呢

q->name=p->name;

p->name=tmp_name;

tmp_phonenumber=q->phonenumber;

q->phonenumber=p->phonenumber;

p->phonenumber=tmp_phonenumber;

tmp_address=q->address;

q->address=p->address;

p->address=tmp_address;

tmp_character=q->character;

q->character=p->character;

p->character=tmp_character; /*p->xxx不是字符串首地址吗,xxx[]的xxx也算个首地址啊*/

}

q=q->next;

p=p->next;

}

test=test->next;

}

}

}

报错信息

friend.c:542:9: error: incompatible types when assigning to type ‘char[20]’ from type ‘char *’

friend.c:543:8: error: incompatible types when assigning to type ‘char[20]’ from type ‘char *’

friend.c:544:8: error: incompatible types when assigning to type ‘char[20]’ from type ‘char *’

friend.c:546:16: error: incompatible types when assigning to type ‘char[20]’ from type ‘char *’

friend.c:547:15: error: incompatible types when assigning to type ‘char[20]’ from type ‘char *’

friend.c:548:15: error: incompatible types when assigning to type ‘char[20]’ from type ‘char *’

friend.c:550:12: error: incompatible types when assigning to type ‘char[200]’ from type ‘char *’

friend.c:551:11: error: incompatible types when assigning to type ‘char[200]’ from type ‘char *’

friend.c:552:11: error: incompatible types when assigning to type ‘char[200]’ from type ‘char *’

friend.c:554:14: error: incompatible types when assigning to type ‘char[200]’ from type ‘char *’

friend.c:555:13: error: incompatible types when assigning to type ‘char[200]’ from type ‘char *’

friend.c:556:13: error: incompatible types when assigning to type ‘char[200]’ from type ‘char *’

e7222fcda1d3c9bc5aa8a06ac919a979.gif

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值