Foreach and for loops
#8

Straight forward example, bugs in your code will be harder to find than this.

pawn Код:
new random_array[ 10 ];//array with 10 slots

foo(  )
{
    for( new i; i < 20; ++i )//loop through 20 slots
    {
        if( i > 10 )//array is now above top index
        {
            random_array[ i ] = 5;//runtime error (out of bounds) causes undefined behaviour
        }
   
    }
   
}
Quote:
Originally Posted by ******
Посмотреть сообщение
I'd suggest you look there more - that's one of the most common bugs I see people asking about.
The first place i look now after spending hours trying to find a bug in my code
Reply


Messages In This Thread
Foreach and for loops - by CONTROLA - 29.05.2012, 07:42
Re: Foreach and for loops - by MP2 - 29.05.2012, 09:07
Re: Foreach and for loops - by CONTROLA - 29.05.2012, 09:35
Re: Foreach and for loops - by CONTROLA - 29.05.2012, 09:42
Re: Foreach and for loops - by CONTROLA - 29.05.2012, 09:55
Re: Foreach and for loops - by iggy1 - 29.05.2012, 09:56
Re: Foreach and for loops - by CONTROLA - 29.05.2012, 09:59
Re: Foreach and for loops - by iggy1 - 29.05.2012, 10:03

Forum Jump:


Users browsing this thread: 1 Guest(s)