| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 387 人关注过本帖
标题:动态链表问题 求教!
只看楼主 加入收藏
winison
Rank: 2
等 级:论坛游民
帖 子:21
专家分:27
注 册:2007-10-27
结帖率:100%
收藏
 问题点数:0 回复次数:1 
动态链表问题 求教!
这是谭浩强书上的例题,我DEBUG运行后报错,到第一个scanf那里就有问题,runtime error 请高手指点!
#if 1
#include<malloc.h>
#include<stdio.h>
#define NULL 0
#define LEN sizeof(struct student)
struct student
{
    long num;
    float score;
    struct student *next;
};
int n;
struct student *creat()
{
    struct student *head,*p1,*p2;
    n=0;
    p1=p2=(struct student *)malloc(LEN);
    scanf("%ld,%f",&p1->num,&p1->score);
    head=NULL;
    while(p1->num!=0)
    {
        n=n+1;
        if(n==1)
            head=p1;
        else
            p2->next=p1;
        p2=p1;
        p1=(struct student *)malloc(LEN);
        scanf("%ld,%f",&p1->num,&p1->score);
    }
    p2->next=NULL;
    return(head);
}
void main()
{
    struct student *p;
    p=creat();
}
#endif
搜索更多相关主题的帖子: 链表 动态 
2009-10-19 10:47
winison
Rank: 2
等 级:论坛游民
帖 子:21
专家分:27
注 册:2007-10-27
收藏
得分:0 
现在过了  奇怪
2009-10-19 11:28
快速回复:动态链表问题 求教!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.021691 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved