what is the termination condition for this C for loop

i found the linked code and found this for loop which is a bit strange for me. i would appreciate if someone could explain me the syntax of this loop to me.
MFG

void patch(Ptrlist *l, State *s)
{
    Ptrlist *next;
    
    for(; l; l=next){
        next = l->next;
        l->s = s;
    }
}

>Solution :

This for loop

for(; l; l=next){

is equivalent to

for(; l != NULL; l=next){

or

for(; l != 0; l=next){

That is the for loop is executed until the controlling expression is equal to 0.

Leave a Reply