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

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

    That means loop control variable is initialized before the for loop .

    For C  code,
    
    int i=0;
    for( ; i <10 ; i++) { } //since it does not allow variable declaration in loop 
    
    For C++  code,
    
    for(int i=0 ; i <10 ; i++) { }  
    

提交回复
热议问题