Andrew
Andrew

Reputation: 434

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'). i.e

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.

Upvotes: 0

Views: 58

Answers (1)

JVMATL
JVMATL

Reputation: 2122

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?

Upvotes: 1

Related Questions