The d_addatbeg( ) function adds a node at the beginning of the existing list. This function too accepts parameter dura, which holds an integer to be added to the Jist.
Memory is allocated for the new node whose address is stored in q. Then num is stored in the data part of the new node. A NULL value is stored in prev part of the new node as this is going to be the first node of the list. The next pari of this new node should contain the address of the first node of the list. This is done through the statement
q -> next = p;
Now what remains to be done is to store the address of this new node into the prev part of the first node and make this new node the first node in the list. This is done through the statements
No comments:
Post a Comment