Multiple Counter Problem In For Loop

后端 未结 7 1142
余生分开走
余生分开走 2020-12-16 10:59

Why is this not valid

for( int i = 0, int x = 0; some condition; ++i, ++x )

and this is

int i, x;
for( i = 0, x = 0; some c         


        
7条回答
  •  青春惊慌失措
    2020-12-16 11:37

    this works:

    for( int i = 0, x = 0; some condition; ++i, ++x )
    

    it's a variable declaration:

    int i, j; // correct
    int i, int j; // wrong, must not repeat type
    

提交回复
热议问题