我有以下链表:
struct node {
int d;
struct node *next;
};
int main()
{
struct node *l = 0;
struct node *k = l;
k = malloc(sizeof(struct node));
/* l->d = 8; */
return 0;
}
Run Code Online (Sandbox Code Playgroud)
为什么注释代码使用错误?我不明白为什么内存没有分配给k
指向同一个节点的节点l
,我使用k
-pointer为它分配内存.