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 *类型的,注意动态分配内存

    评论

报告相同问题?

悬赏问题

  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站