0

I'm dealing with pset5 (speller.c), and I chose trie to run the program. when I compiled it, it said:

dictionary.c:25:1: error: type specifier missing, defaults to 'int' [-Werror,-Wimplicit-int]

root = (node *)malloc(sizeof(node));

^~~~

Is there something wrong with my struct?

typedef struct _node
{
    struct _node * alphas[27];
    bool is_word;
}node;

node * root;
root = (node *)malloc(sizeof(node));

But when I change it to a variable(not pointer ant more):

node root;

it works properly, why is that?

Thanks!

Oh, sorry, I forgot to say that I declared the struct and the struct pointer as global declarations, could that be the problem? because the rest of the code just worked well...

3
  • your code compiled successfully at my appliance without any errors, please post more of your code maybe the error is related to something else – Michael Nageh Feb 13 '15 at 11:38
  • Oh, sorry, I forgot to say that I declared the struct and the struct pointer as global declarations, could that be the problem? because the rest of the code just worked well... – Y_C Feb 13 '15 at 12:08
  • You can change root = (node *)malloc(sizeof(node)); to root = malloc(sizeof(node)); – David Sep 12 '15 at 17:29

You must log in to answer this question.

Browse other questions tagged .