我正在尝试使用内存迭代地创建“节点”。我的代码目前只是说明了它的地址,实际上并没有尝试在链接列表中创建链接。
这是 a 的代码node
:
struct node {
int num;
node *next;
};
这是代码malloc()
node *etc = (node*) malloc(sizeof(node));
etc->num = 1;
etc->next = NULL;
cout << etc << endl;
for (int i=2; i<=10; i++) {
node *new_etc;
new_etc = (node*) malloc(sizeof(node));
cout << new_etc << endl;
}
编辑
输出:
0xcff010
0xcff030
0xcff050
0xcff070
0xcff090
0xcff0b0
0xcff0d0
0xcff0f0
0xcff110
0xcff130