Mail Archives: djgpp/1998/03/05/09:41:17
At 19:48 1998.03.04 +0900, Bum-Seok Hyun wrote:
>(...)
>
>Main body of my test code is
>
>for(int i=1 ; i<10001 ; i++)
> for(int j=1 ; j<10001 ; j++)
> for(int k=1 ; k < 11 ; k++) sum += i;
>
>Above code is ,of course , for C++.
>
>In C code, I just moved variable definitions
>into the first line of the code.
>Like,
>
>int i,j,k;
>float sum;
>
>(...)
>
Perhaps you could try changing the last assignment to
sum += j;
and making j vary from -5000 to <5001 ?
This way you won't get out of int range
(I assume sum is initialized to 0);
I don't think this is the problem, though.
On my system (PGCC, EGCS 1.0.1 :-)
there were no significant differences between C, C++
and C++ with declarations inside for
(about 49s in each case).
Maciej.
- Raw text -