lcc编译出错..

//vararr2d.c -- functions using VLAs从书上COPY下的正确的代码,LCC得到了错误结果
#include <stdio.h>
#define ROWS 3
#define COLS 4
int sum2d(int rows, int cols, int ar[rows][cols]);
int main(void)
{
int i, j;
int rs = 3;
int cs = 10;
int junk[ROWS][COLS] = {
{2,4,6,8},
{3,5,7,9},
{12,10,8,6}
};

int morejunk[ROWS-1][COLS+2] = {
{20,30,40,50,60,70},
{5,6,7,8,9,10}
};

int varr[rs][cs]; // VLA

for (i = 0; i < rs; i++)
for (j = 0; j < cs; j++)
varr[i][j] = i * j + j;

printf("3x5 array\n");
printf("Sum of all elements = %d\n",
sum2d(ROWS, COLS, junk));

printf("2x6 array\n");
printf("Sum of all elements = %d\n",
sum2d(ROWS-1, COLS+2, morejunk));

printf("3x10 VLA\n");
printf("Sum of all elements = %d\n",
sum2d(rs, cs, varr));
getchar();
return 0;
}

// function with a VLA parameter
int sum2d(int rows, int cols, int ar[rows][cols])
{
int r;
int c;
int tot = 0;

for (r = 0; r < rows; r++)
for (c = 0; c < cols; c++)
tot += ar[r][c];

return tot;
}

这段代码结果猜也猜得到把,但在LCC里编译得到了错误的结果。。。
3963907,-235707,270
前两个结果显然是错误的(用DEVC++编译得到了正确结果,不过要加个GETCHAR()...
)但奇怪的是最后一个结果是正确的?难道LCC不能完美支持VLA么?。。。
PS:现在外国的网站也连不上去几个了。。郁闷中。。。
[1465 byte] By [Kearnel] at [2008-1-9]
# 1
这里也有一段代码,在LCC下可以通过,在DEVC++下通不过。。郁闷的说。。
还是我哪里错了?

#include <stdio.h>
int big(int []);
int main(void)
{
int x[5]={-1,2,25,8,17};

printf ("%d",big(x));
getchar();
return 0;
}
int big(int ar[])
{
int big1,n;
for(n=0;n<=4;n++)
big1=big1>(ar[n])?big1:(ar[n]);
return big1;

}
Kearnel at 2007-10-19 > top of Msdn China Tech,C/C++,C语言...
# 2
楼上,我的dev-cpp可以编译你的程序,没有错。
coldwindtang-风 at 2007-10-19 > top of Msdn China Tech,C/C++,C语言...
# 3
标准与编译器向来就有个互动的过程
不要和编译器过不去了
你要是觉得你的代码符合标准 你就找一个兼容标准的编译器
要是你的代码符合编译器 你就用那个编译器