简体   繁体   English

将结构中的位置分配给变量(或指针)

[英]Assign place in struct to variable (or pointer)

My struct looks like this: 我的结构看起来像这样:

struct Node
{
    int value;
    struct Node *children[26];
};

typedef struct Node *List;

I would like to assign first (main) struct to variable (or pointer) so I could come back to it (after moving to 'substructs'). 我想将第一个(主)结构分配给变量(或指针),这样我可以回到它(移至“子结构”之后)。 ie

start = malloc(sizeof(struct Node));
(this variable) = start;
list = (this variable);
list = list -> children[25];
...
list = (this variable) //We're again in main/first struct.

so…. 所以…。 why can't you say: 你为什么不能说:

List start = malloc(whatever);
List list = start;
list = list->children[25]; // index 26 is out of bounds…

Is the problem that you're not sure you can declare something of type List? 您不确定是否可以声明List类型的问题吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM