I try to access \"next\" in another structure, but failed although i have tried many ways.
Here is the nested structure:
struct list_head {
struct l
In your definition, you are defining list to be an object as below
typedef struct {
char *key;
char *value;
struct list_head list; // This is an object
}dict_entry;
Hence, you will de-reference next through the . operator as d->list.next. The first level of de-referencing i.e. d->list requires -> operator as d is defined to be a pointer. For next, since list is an object and not a pointer, you would have to use . operator.
list is not declared as a pointer, so you don't use the -> operator to get its members, you use the . operator:
while (d->list.next != NULL) {
}
A different fix:
typedef struct {
char *key;
char *value;
struct list_head *list;
}dict_entry;
This way, your original code attempting to refer to next would compile.