任意位置的声明、for 中的声明与 // 注释

版本新特性 / C99

// *** before: ***
/* C89: every declaration stands at the top of a block, before the
   first statement, and a comment is only the slash-star kind */
int i;
int sumOld;
double averageOld;

sumOld = 0;
for (i = 1; i <= 4; i++)
    sumOld += i;
averageOld = sumOld / 4.0;
/* averageOld is 2.5 */

printf("averageOld is %g\n", averageOld);

// *** in version C99: ***
//a variable is declared where its value first appears
int sum = 0;
for (int i = 1; i <= 4; i++)      //this i lives only inside the loop
    sum += i;
double average = sum / 4.0;
//average is 2.5

//and the // comment itself is new in C99 as well
printf("average is %g\n", average);