Declaration difference?
问题 What is the difference when we declare variable before using in loop and when define variable in loop. I am talking about this situation int i; for(i=0; i<100; i++); and for(int i=0; i<100; i++); 回答1: In the first case it is supposed that variable i will be used also after the loop as for example int i; for(i=0; i<100; i++); printf( "i = %d\n", i ); Nevertheless it would be much better to write the following way int i = 0; for( ; i<100; i++); printf( "i = %d\n", i ); In this case we will get