I have set up the following structs:

typedef struct lineList
	{
	    int lineNum;
	    struct lineList* Next;
	}*Line;

typedef struct DictionaryList
	{
	    char* word;
	    Line lines;
	    struct dictionaryList* Next;
	}*Dictionary;
 and then I have defined:
 Dictionary head = NULL; /*is a pointer to head of dictionary list */

 Dictionary node = (Dictionary)malloc(sizeof(struct DictionaryList));
 ...

node->Next = head;

and I get the folowings error: assignment from incompatible pointer type
I don't understand why both head and node are the same type: Dictionary.

Recommended Answers

All 2 Replies

change it to this

typedef struct DictionaryList* Dictionary;
struct DictionaryList
{
char* word;
Line lines;
DictionaryList* Next;
};

The reason is that DictionaryList (defined on line 7) and dictionaryList (used on line 11) are different types.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.