这个程序哪儿出错,或者还应该改进哪儿
#include<stdio.h>#include<malloc.h>
typedef struct linka
{
int data;
struct linka *next;
}link;
void reverse(link *&head)
{
if(head==NULL)return;
linka *pre,*cur,*ne;
pre=head;
cur=head->next;
while(cur)
{
ne=cur->next;
cur->next=pre;
pre=cur;
cur=ne;
}
head->next=NULL;
head=pre;
while(head)
{
printf("=%d=",head->data );
head=head->next ;
}
}
void main(void)
{
link *p,*q;
link *head=(link *)malloc(sizeof(link));
p=head;
for(int i=0;i<10;i++)
{
p->data =i+1;
q=(link *)malloc(sizeof(link));
p->next =q;
p=q;
}
p->next =NULL;
reverse(head);
}