| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 865 人关注过本帖, 1 人收藏
标题:简单链表输入输出,不知道问题在哪?求大神指教。
只看楼主 加入收藏
陌心丶沉沦
Rank: 1
来 自:陕西西安
等 级:新手上路
帖 子:6
专家分:5
注 册:2017-6-18
结帖率:0
收藏(1)
已结贴  问题点数:10 回复次数:2 
简单链表输入输出,不知道问题在哪?求大神指教。
#include<stdio.h>
#include "malloc.h"
#define NULL 0
#define LEN sizeof(struct student)
struct student
    {
        long num;  
        float score;
        struct student*next;
    };
int n;
struct student *create()
    {
        struct student*head;
        struct student*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 p1=p2->next;
                p2=p1;
                p1=(struct student*) malloc(LEN);
                scanf("%ld,%f",&p1->num,&p1->score);
            }
        p2->next=NULL;
        return(head);
    }
void print(struct student head)
{struct student* p;
    p=head;
    if(head!=NULL)
    do
    {
        printf("num=%ld   score=%5.1f\n", p->num, p->score);
        p = p->next;
    } while (p!=NULL);   
}
int main()
{    struct student*head;
    head=create();
    print(head);
    return 0;
}
编译问题:
1. error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'struct student' (or there is no acceptable conversion)
2.error C2676: binary '!=' : 'struct student' does not define this operator or a conversion to a type acceptable to the predefined operator
3.error C2664: 'print' : cannot convert parameter 1 from 'struct student *' to 'struct student'
        No constructor could take the source type, or constructor overload resolution was ambiguous
Error executing cl.exe.
搜索更多相关主题的帖子: struct student num score head 
2018-05-03 18:42
童生
Rank: 6Rank: 6
等 级:侠之大者
威 望:8
帖 子:205
专家分:455
注 册:2018-3-7
收藏
得分:10 
void print(struct student * head)
//#define NULL 0
2018-05-03 19:54
陌心丶沉沦
Rank: 1
来 自:陕西西安
等 级:新手上路
帖 子:6
专家分:5
注 册:2017-6-18
收藏
得分:0 
谢谢 大佬!!!!
2018-05-03 22:08
快速回复:简单链表输入输出,不知道问题在哪?求大神指教。
数据加载中...
 
   



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

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