一个把一个链表完全拷贝到另外一个链表的方程,请问那边出错了
MailNode *copylist(MailNode *messageList){
MailNode *q, *r, *m,*temp;
temp=messageList;
q = (MailNode *)malloc(sizeof(MailNode));
if (q == NULL)
exit(1);
q->from = temp->from;
q->to = temp->to;
q->subject =temp->subject;
q->date = temp->date;
q->messageId = temp->messageId;
q->inReplyTo =tempt->inReplyTo;
q->content = temp->content;
q->status = temp->status;
q->priority =temp->priority;
q->msgNum =temp->msgNum;
// include all your struct value
m = q;
while (messageList->next != NULL)
{
r = (MailNode *)malloc(sizeof(MailNode));
if (r == NULL)
exit(1);
r->from = temp->from;
r->to = temp->to;
r->subject =temp->subject;
r->date = temp->date;
r->messageId = temp->messageId;
r->inReplyTo =tempt->inReplyTo;
r->content = temp->content;
r->status = temp->status;
r->priority =temp->priority;
r->msgNum =temp->msgNum;
q->next = r;
q = q->next;
temp=temp->next;
}
q->next = NULL;
return m;
}