2021年4月28日星期三

understanding this form of for loop in c

I have come across this For loop in c and I am struggling to make sense of it this is the loop Context: loop is going over a linked list

POINTER **prev=head, *curr, *next;     for(curr = *head; curr; prev = &curr->link, curr = curr->link)  

To my knowledge I can gather that curr will begin at the head of the list. what is curr; does this just mean the pointer current is not NULL? normally in that section it would be something like i < 5;

And lastly, prev = &curr->link, curr = curr->link - I have never seen a comma separating the incrementor (if thats what it is) I also dont understand what that section is doing.

Could someone possibly break this loop down for me to help me understand what is going on?

https://stackoverflow.com/questions/67310205/understanding-this-form-of-for-loop-in-c April 29, 2021 at 10:22AM

没有评论:

发表评论