mercredi 27 juillet 2016

For loop Syntax in C [duplicate]

I have a strange syntax of for loop here :

for(--index ; index>=0 ; --index)     // (--index) instead of (forInit) 
{
    //code
}

I know for syntax is like this :

for ( [ForInit] ; [Expression] ; [ForUpdate] ) Statement

How do we have --index instead ForIniti in the loop. I thought that we can only initialise a variable at that place or can leave it blank like this :

for( ; index>=0 ; index--)
    {
      //code
    }

I haven't been introduced to this syntax before. Please explain why this is syntactically correct.

Aucun commentaire:

Enregistrer un commentaire