I'm tackling load and decided to make a create_node function for allocating memory, NULLing all children and setting is_word as false.
What I wrote is essentially the same as in this question
struct node create_node(void)
{
node *n = malloc(sizeof(node));
if (n == NULL)
{
return n;
}
n->is_word = false;
for (int x = 0; x < N; x++)
{
n->children[x] = NULL;
}
return n;
}
However I can't declare a new node outside of that function, either getting a
error: incompatible pointer types initializing 'node *' (aka 'struct node *') with an expression of type 'node (void)' (aka 'struct node (void)')
node *new_node = create_node;
or
error: expression is not assignable
for
node *new_node;
&new_node = create_node;
Since from the answered question I understand that I'm getting an address back.
I know that it's a bad way of figuring things out, but I have tried all variations of *, & and nothing , declaring an empty new node before trying to assign it to the function and still stuck.