单链表应该怎么倒置啊
struct tree{int data;
struct tree *next;
};
void main()
{struct tree head,a,b,c,*p,*q,*i;
head.next=&a;a.data=1;
a.next=&b;b.data=2;
b.next=&c;c.data=3;
c.next=NULL;
p=head.next;
do
{printf("%d ",p->data);
p=p->next;
}while(p!=NULL);
q=&head; //这里总是无限循环
while(q)
{i=q;
q=i->next;
q->next=head.next;
head.next=q;
}
应该怎么改啊,高手们帮帮忙

戒烟真难啊,去楼顶抽个,没人发现