17.06.2014, 17:27
Hey!
I was scripting and when I did the next;
The code would only print;
Then I tried these two (Basically the same);
The code (And crashdetect straight after it) printed;
Then I got suspicious something had to be wrong as the first code would just loop with 0 and the second codes go to 2.
changed it like this;
And it is still printing;
The if statement is not bugging when it's on -1, as crashdetect isn't printing for accessing at negative index but it is bugging when 'i' gets to 2, as crashdetect is printing. How is this possible?!
Best regards,
Jesse
EDIT:
Even after changing the code to this;
Crashdetect is printing;
I was scripting and when I did the next;
pawn Код:
for(new i = 0; i < 1; i++)
{
printf("i = %d", i);
}
Код:
i = 0
pawn Код:
for(new i = 0; i < 2; i++)
{
printf("i = %d", i);
}
// and
for(new i = 0; i <= 1; i++)
{
printf("i = %d", i);
}
Код:
i = 0 i = 1 Run time error 4: "Array index out of bounds" Accessing element at index 2 past array upper bound 1
changed it like this;
pawn Код:
for(new i = -1; i < 2; i++)
{
printf("i = %d", i);
if(i == 0 || i == 1)
{
}
}
Код:
i = 0 i = 1 Run time error 4: "Array index out of bounds" Accessing element at index 2 past array upper bound 1
Best regards,
Jesse
EDIT:
Even after changing the code to this;
pawn Код:
for(new i = 0; i < 2; i++)
{
if(i == 0 || i == 1)
{
if(i == 2) break;
}
}
Код:
Run time error 4: "Array index out of bounds" Accessing element at index 2 past array upper bound 1