数据结构里的一个问题
#include<stdlib.h>#include<stdio.h>
#define MAX 10
typedef struct node{
int weight;
struct node *next;
}listnode,*listnodeptr;
int main()
{
int i = 0,j = 0;
listnodeptr bt,p;
bt = (listnodeptr)malloc(sizeof(listnode));
p = bt;
for(;i<MAX;++i){
p->next = NULL;
p->weight = 0;
p = p->next;
p = (listnodeptr)malloc(sizeof(listnode));
}
p = bt;
for(;j<MAX;++j){
printf("NO.%d node is %d\n",j+1,p->weight);
p = p->next;
}
system("pause");
return 0;
}
最后显示的是 NO.1 node is 0
然后其余的九个节点并未显示,并且出现RUN-TIME error的报错
求大神指教啊~~~~