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

后端 未结 8 1060
猫巷女王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:40

    The for construct is basically ( pre-loop initialisation; loop termination test; end of loop iteration), so this just means there is no initialisation of anything in this for loop.

    You could refactor any for loop thusly:

    pre-loop initialisation
    while (loop termination test) {
    ...
    end of loop iteration
    }
    

提交回复
热议问题