| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 417 人关注过本帖
标题:书上例题无法运行,请大家一起帮忙诊断。谢谢
取消只看楼主 加入收藏
小戏
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2012-7-11
结帖率:83.33%
收藏
已结贴  问题点数:12 回复次数:2 
书上例题无法运行,请大家一起帮忙诊断。谢谢
#include<stdio.h>
#include<malloc.h>

#define LEN sizeof(struct student)
struct student
    {int num;

    float score;
    struct student *next;
    };
   int n;
struct student *creat()
{
struct student *head;
    struct student *p1,*p2;
    n=0;
    p1=p2=(struct student*)malloc(LEN);
    scanf("%d,%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("%d,%f",&p1->num,&p1->score);
    }
    p2->next=NULL;
    return(head);
}


void print(struct student *head)
{struct student *p;
printf("\nNow,These%d records are:\n",n);
p=head;
if(head!=NULL)
do
{printf("%1d %f\n",p->num,p->score);
p=p->next;
}while(p!=NULL);
}
void main()
{
struct student *head;
head=creat();
pritn(head);

}
搜索更多相关主题的帖子: next include 
2012-08-18 20:53
小戏
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2012-7-11
收藏
得分:0 
新手自学当中,还请各位师兄多多指教,谢谢!
2012-08-18 21:28
小戏
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2012-7-11
收藏
得分:0 
谢谢各位,由于新学,很多东西都没有信心,只能靠不断的错误来积累经验,更没有想到只是因为两个字母的位置问题而出现错误。真的谢谢各位师兄的赐教!
2012-08-20 11:18
快速回复:书上例题无法运行,请大家一起帮忙诊断。谢谢
数据加载中...
 
   



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

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