Monicase 2016-03-06 06:50 采纳率: 25%
浏览 3055

C语言 结构体嵌套 中的问题,

问题还没有解决。。。[请看到的老师们 帮忙看看,谢谢,麻烦了]

等待中~

图片说明我大概的想法是用结构体嵌套,

嗯~ 打个比喻, 班上每个同学的学号是外结构体的数据, 之后用学号来找同学。

每个同学的各科成绩是内结构体。

我现在想做一个同学个各科成绩录入, 可是在科目一 链接 科目二 在这儿错了,

图中是DeV C++ 编译软件

而VC++ 报错是:E:\C\GG\GGGG.CPP(42) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'struct date *' (or there is no acceptable conversion)

如果把图中阴影部分改为: head->full = * front; 则不报错。

希望老师们 说下如何解决, 以及为何该为 head->full = * front; 之后不报错,却会终止程序,[ 其中的问题是什么 ]

刚刚创建的CSDN账号,没有财富值,-。-

图片说明

老师, 不怎么会动态分配 啊。。。

typedef struct date{
int prestoreboole; // 1/0 进行位与运算;与grade中boole 相同;
int cut; // 代表时候被删掉,1代表删掉,0代表不被删掉。
struct date *neinext; // 内表中的指针域

}Date,*linklist;

typedef struct grade{
int boole;
int number;
double result;
struct date *full;

struct grade *next;
}Grade,*LinkList;

struct grade *Copy( struct grade *prestorehead , struct grade *originalhead){

struct grade *neworiginalhead = originalhead; 
struct grade *newprestorehead = prestorehead; 
struct date *front = NULL , *newpoint;
LinkList head;

do{ 
//******************************************************************************
front = (linklist)malloc(sizeof(Date));     //     [     这是我刚刚加的,是这样分配吗?     老师您能凑合这些代码,  分配一下,标注出来吗?]

//*******************************************************************






newpoint = (linklist)malloc(sizeof(Date)); 
newpoint->prestoreboole = neworiginalhead->boole;
newpoint->neinext = NULL;

        if( front == NULL ){
            front = newpoint;
            head->full = front;     
        }else{
          front->neinext = newpoint->neinext;
          front = front->neinext;

        }
neworiginalhead = neworiginalhead->next;

}while(neworiginalhead != NULL);
head->full->cut = 1;  //  这是第一个数,需要删除   
return head;

}

  • 写回答

5条回答

  • xSeeker~ 2016-03-06 07:01
    关注

    你定义的grade中的full 是 struct data 类型的,阴影处你却将,strcut data *类型的front赋给了 struct data 类型,所以会报error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'struct date *' (or there is no acceptable conversion)
    建议将grade中的full 改为 struct data *类型的,注意动态分配内存

    评论

报告相同问题?

悬赏问题

  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用