首页 新闻 赞助 找找看

关于动态链表及指针数组

0
悬赏园豆:10 [已关闭问题] 关闭于 2013-03-25 16:35

下面这个程序:

#include<stdio.h>
#include<stdlib.h>
struct student
{
int num;
float score;
struct student *next;
};
int main()
{
struct studet *p[4],*head,*pt;
p[0]=(struct student *)malloc(1000);
pt=head=p[0];
for(int i=0;i<=2;i++)
{
p[i+1]=(struct student * )malloc(1000);
scanf("%ld %f",&p[i+1]->num,&p[i+1]->score);
p[i]->next=p[i+1];
}
p[3]->next=NULL;
while(pt!=NULL)
{
printf("%d %f\n",pt->num,pt->score);
pt=pt->next;
}
return 0;
}

调试的时候显示是在指针数组那个地方出了问题,求大神指教

墨梅冷骨的主页 墨梅冷骨 | 初学一级 | 园豆:184
提问于:2013-03-25 16:08
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册