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 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码