标题:一个把一个链表完全拷贝到另外一个链表的方程,请问那边出错了
取消只看楼主
ian116
Rank: 1
等 级:新手上路
帖 子:28
专家分:2
注 册:2009-5-15
结帖率:85.71%
已结贴  问题点数:20 回复次数:0 
一个把一个链表完全拷贝到另外一个链表的方程,请问那边出错了
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;
}
搜索更多相关主题的帖子: 拷贝 链表 方程 
2009-10-18 11:31



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-288974-1-1.html




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

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