Sun Studio 12: C User's Guide

D.1.15 Declaration in for-Loop Statement

6.8.5 Iteration statements

The C compiler now accepts a type declaration as the first expression in a for loop-statement:


for (int i=0; i<10; i++){ //loop body };

The scope of any variable declared in the initialization statement of the for loop is the entire loop (including controlling and iteration expressions).