建立链表哪里出现问题了,求解,谢谢
//建立双向循环链表 void create_d_list ( struct d_list **headp, int *p )
{
struct d_list *head = NULL, *tail;
if( p[0] == 0 )
*headp = NULL;
else
{
head = ( struct d_list * ) malloc ( sizeof( struct d_list ) );
//head->data = *p++;
head->data = *p;
tail = head;
printf("head->data=%d\n",head->data);
while( *p )
{
tail->next = ( struct d_list * ) malloc ( sizeof ( struct d_list ) );
tail->next->prior = tail;
//tail = head->prior; //
//tail = tail->next;
head = tail->next; //
tail->data = *p++;
}
printf("tail->data=%d\n",tail->data);
tail->next = head;
head->prior = tail;
}
*headp = head;
}
[[it] 本帖最后由 henyue 于 2008-8-15 15:49 编辑 [/it]]