Defining a memory location using
struct node { int item; node *next; };
and assuming it ptrpoints to a linked list, is there a difference between putting while(ptr!=NULL)vs while(ptr->next!=NULL)in a loop through the list until a null pointer is reached?
ptr
while(ptr!=NULL)
while(ptr->next!=NULL)
while(ptr->next!=NULL) will not go through your last node.
By the time you get to your last node, it ptr->nextwill be null and it will exit the loopwhile
ptr->next
while
while(ptr != NULL)will iterate through all of your linked lists when it while(ptr->next != NULL)misses the last item.
while(ptr != NULL)
while(ptr->next != NULL)
, node, , .
Source: https://habr.com/ru/post/1502485/More articles:How to make a countdown in angularjs with a timer directive - javascriptmongodb disable option unavailable - databaseGet a list of all sections related to the submission - iosExclamation-encodeUriComponent with javascript? - javascriptColor output in Sublime Text 2 console? - sublimetext2random user can access mysql db - pythonDetecting iframe changes before server response - javascriptServe static pages and REST services with Spring - javaYaw conversion, step And roll to vector x, y, z in world coordinates - 3dCan a server handle multiple sockets in a single thread? - socketsAll Articles