0

To make the load function, I decided to use something like a trie called 'storage'. However, I seem to be getting an error. Below is my code.

typedef struct stroage
{
    char c;
    struct storage *nextList;
    struct storage *nextElement;
}
storage;

storage *createNode(char a){
    storage *n = malloc(sizeof(storage));
    n->c = a;
    n->nextList = n->nextElement = NULL;
    return n;
}

void addNode(char c, storage *a){
    storage *n = createNode(c);
    while (a->nextElement != NULL){
        a = a->nextElement;
    }
    a->nextElement = n;
}

The error I am getting is this:

incompatible pointer types assigning to 'storage *' (aka 'struct stroage *') from 'struct storage *' [-Werror,-Wincompatible-pointer-types] for the line below.

a = a->nextElement;

It says the pointer types are incompatible even though both are 'struct storage *'. How do I resolve this?

1

Typo: You don't have a struct storage, you have a struct stroage. Change them to all use the same name.

1
  • OMG THANKS SO MUCH
    – Aryan Jain
    Nov 27 '17 at 14:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .