【发布时间】:2013-12-13 05:04:12
【问题描述】:
我目前正在尝试将一个指针分配给一个名为 totheright 的结构(它是一个链表节点)。指向结构/列表的指针当前位于另一个称为矩形的结构中。当我尝试这样做时遇到错误。
currect->right = malloc(sizeof(totheright));
righthead = current->right;
以下是函数中的声明:
rect *currect = NULL;
totheright *righthead = NULL;
标题中的结构定义:
typedef struct _totheright {
int rect;
struct _totheright *right;
} totheright;
typedef struct _rect {
int thisrect;
struct totheright *right;
int left;
double width;
double height;
double xcord;
double ycord;
struct _rect *next;
} rect;
【问题讨论】:
-
righthead = current->right;应该是righthead = currect->right;
标签: c pointers structure variable-assignment