typedef struct listnode *nodePtr;
typedef struct listnode {
//declaration of data fields
nodePtr link; //declaration of link field
};
typedef struct term *polynomial;
typedef struct term {
int coef;
int exp;
polynomial link;
};
polynomial A;
typedef struct term *listPtr;
typedef struct term {
int coef;
int exp;
listPtr link;
};
listPtr A, B, C; //2x^500 + 10x - 1
A = (listPtr)malloc(sizeof(*A));
B = (listPtr)malloc(sizeof(*B));
C = (listPtr)malloc(sizeof(struct term));
A->coef = 2;
A->exp = 500;
A->link = A;
B->coef = 10;
B->exp = 1;
B->link = C;
A->coef = -1;
A->exp = 0;
A->link = NULL;
p = firstPtr;
while(p != NULL) {
if(p->data == "Rings") //code
p = p->link;
}
for(p = firstPtr; p != NULL; p = p->link) {
if(p->data == "Rings") //code
}
P → N
N → N
never go to NULL