该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
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 *’