24小时热门版块排行榜    

查看: 2622  |  回复: 12
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

好好努力

金虫 (正式写手)

[求助] 谭浩强C语言教材,P298页照着输入都不对!求原因

#include
#include
#define NULL 0
#define LEN sizeof(struct student)

struct student
{
        long num;
        float score;
        struct student *next;


};
int n;
struct student *creat(void)
{
   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++;
           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 *lin1=creat();

}

//scanf("%ld%f",&p1->num,&p1->score);好像是这一句出错,但是将float score改成int score就不会出错了,下面的%f相应的改成%d就没错了!真搞不懂了,望高手赐教!
回复此楼
好好就好!!!
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

rsb_long

至尊木虫 (著名写手)

C语言对于不同的编程环境运行结果是不同的,考试的时候最担心的就是系统的问题,目前使用的VC环境有很多的版本,你需要认真对比一下不同版本的区别
12楼2014-02-22 15:58:51
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 好好努力 的主题更新
信息提示
请填处理意见