Home > Archive > VC Language > November 2005 > Newbie Q- For Loop Continues - Help!
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Newbie Q- For Loop Continues - Help!
|
|
| lakepeir@yahoo.com 2005-11-27, 9:58 pm |
| Hello,
I need help with my for loop. The loop does not end. It should end
when i is one less than uBound. What happens is that when i is 1 less
than uBound, the loop continues with a weird value 5432325 (I have no
idea how this value is generated, uBound is less than 10.) and then i
is equal to zero again. Here's the code:
for (int i=0; i < uBound; i++)
for (int j=0; j < uBound2; j++)
{
SafeArrayPutElement(psaArray, &lVal, &j);
}
Thanks!
| |
| Victor Bazarov 2005-11-27, 9:58 pm |
| lakepeir@yahoo.com wrote:
> I need help with my for loop. The loop does not end. It should end
> when i is one less than uBound. What happens is that when i is 1 less
> than uBound, the loop continues with a weird value 5432325 (I have no
> idea how this value is generated, uBound is less than 10.) and then i
> is equal to zero again. Here's the code:
> for (int i=0; i < uBound; i++)
> for (int j=0; j < uBound2; j++)
> {
> SafeArrayPutElement(psaArray, &lVal, &j);
>
> }
This code does not contain anything that would suggest the behaviour as
you have described. What you have is probably a very unpleasant and
difficult to catch memory overrun error where you simply stomp all over
your own stack. Make a breakpoint to watch for the changes in the 'i'
variable and verify that only your 'i++' actually does that. If you
discover another place that does that, research it carefully.
V
|
|
|
|
|