链表排序函数出错在哪里?
void order ( ){
struct carinfo *temp,*p1,*p2;
p1=head;
p2=p1->next;
p1=p2=(struct carinfo*) malloc(sizeof(struct carinfo));
while(p2!=NULL)
{ if(strcmp(p1->num,p2->num)>0)
memcpy(p1,temp,sizeof(struct carinfo));
memcpy(p1,p2,sizeof(struct carinfo));
memcpy(p2,p1,sizeof(struct carinfo));
p1=p1->next;
p2=p1->next;
}
printf("the ordered content as follow\n");
struct carinfo *p;
p=head;
while(p!=NULL)
{
printf("%s %s %s %f %d %s %s\n",p->num,p->name,p->type,p->price,p->date,p->chexing,p->corporation);
p=p->next;