Initializing the variables in the for statement gives the variables a bit different scope. If you define the variable in the for statement, the variable will only be accessible in the loop.
You normally don't need your loop counter value to be used outside the loop (there might be the odd case where this might make sense).
In most cases, yes, it will be better to keep variable initialization in the for statement. It will keep your code nice and readable.
|