#include <stdio.h>
#include <stdlib.h>
typedef int element;
struct cell {
element e;
struct cell *p;
};
typedef struct cell* CELL;
int main() {
CELL* p;
p = (CELL*) malloc (sizeof(struct cell));
p->e = 8; /* This ain't working */
*p.e = 8; /* This doesn't help anything either */
return 0;
}
我刚开始接触malloc
,我刚刚作出了一个指针到新创建的CELL
,这是一个struct
。现在我试图用一些价值来填补它,但是我受到了一个不友好的“对成员e的请求”的欢迎,而不是一个结构或联盟。“我确实指向了一个包含e成员的struct
,或者至少,这就是我想我做到了。为什么会失败?为什么我不能通过它的指针访问这个结构体?