Why i++ does not change its value in Xcode
I am a newbie of C++ programmer in the environment of XCode 4, and the
following codes that work in VC windows and C::B in Linux, however, fails
in XCode 4:
int local=0;
int a[100];
int i;
for(i=0; i<100; i++)
{
a[local] = i*i*i;
local++;
}
The error message I have obtained is:
Thread 1: EXC_BAD_ACCESS ....for a[local] = i*i*i;
Then I debug the codes, and found that during the iteration for(i=0;
i<100; i++) the local variable i does not change and remains 0 all the
time. I was wondering what I should do in this situation. Thanks.
No comments:
Post a Comment