链表猴子吃桃
#include<stdio.h>#include<stdlib.h>
#define NULL 0
typedef struct linknode
{
int data;
struct linknode *next;
}node;
node *head;
void creat()
{
node *p,*s;
int peaches=1;
int day=10;
head=(node*)malloc(sizeof(node));
p=head;
while(day>0)
{
s=(node*)malloc(sizeof(node));
s->data=peaches;
p->next=s;
p=s;
peaches=(peaches+1)*2;
day--;
}
p->next=NULL;
p=head;
head=head->next;
free(p);
}
void print()
{
node *p;
p=head;
int day=10;
while(p&&day>0)
{printf("%d:%d\n",day,p->data);
p=p->next;
day--;
}
}
void main()
{
creat();
print();
}
在print函数一直有错 怎么回事