What does it mean when the first “for” parameter is blank?

后端 未结 8 1097
猫巷女王i
猫巷女王i 2020-12-20 19:27

I have been looking through some code and I have seen several examples where the first element of a for cycle is omitted.

An example:

for ( ; hole*2          


        
8条回答
  •  清酒与你
    2020-12-20 19:46

    Suppose you wanted to

    for (hole=1 ; hole*2 <= currentSize; hole = child)
    

    But the value of hole just before the for loop was already 1, then you can slip this initilization part of the loop:

    /* value of hole now is 1.*/
    for ( ; hole*2 <= currentSize; hole = child)
    

提交回复
热议问题