标题:各位大神,请问我的动态链表程序怎么运行崩溃
取消只看楼主
JackBrian
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2015-2-13
结帖率:50%
已结贴  问题点数:20 回复次数:0 
各位大神,请问我的动态链表程序怎么运行崩溃
#include <stdio.h>
#include <stdlib.h>
#define LEN sizeof(struct Date)
struct Date
{
    int num;
    int score;
    struct Date *next;
};
int n;
struct Date *creat(void)
{
    struct Date *head;
    struct Date *p1,*p2;
    p1=p2=(struct Date *)malloc(LEN);
    scanf("%d,%d",&p1->num,&p1->score);
    n=0;
    head=NULL;
    while(p1->num!=0)
    {
        n=n+1;
        if(n==0) head=p1;
        else p2->next=p1;
        p2=p1;
        p1=(struct Date *)malloc(LEN);
        scanf("%d,%d",&p1->num,&p1->score);
    }
    p2->next=NULL;
    return(head);
}

int main()
{
    struct Date *pr;
    pr=creat();
    printf("\nnum=%d\nscore=%d",pr->num,pr->score);
    return 0;
}
搜索更多相关主题的帖子: 链表程序 动态 include 
2015-04-15 09:59



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-444019-1-1.html




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

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