> 476 p=p->head->next;

> I don't know what is the problem. Could you help me? Thank you.

You should check p->head isn't NULL before trying to do p=p->head->next

What are these for?

Code:

typedef struct monomial_node /* a monomial denotes a monomial P_{i,k}^{l} \cdots P_{i',k'}^{l'} */
{
node y;
int coeff; /* coeff is the coefficent of the monomial */
struct monomial_node *next;
struct monomial_node *head;
} monomial_node, *monomial;
typedef struct polynomial_node /* a polynomial denotes a sum of some monomials */
{
monomial m;
struct polynomial_node *next;
struct polynomial_node *head;
} polynomial_node, *polynomial;

If you've got say 5x^2+10x+20, then you have 3 polynomial nodes, where each instance of the 'm' member is initialised to 5x^2, 10x and 20

I would also re-think the idea of storing a head pointer in each node. If you delete the head node of a list, you have to change the entire list to point to the new head node (of the list).

Linked list - Wikipedia, the free encyclopedia

Draw out some pictures so you're clear on paper exactly what is stored in a node, and how all the pointers are arranged.