I have nested for loops, where I'm going over an array.
#define ARRAYSIZE 10
for(drawx = 1; drawx<(ARRAYSIZE - 1); ++drawx)
is the first for
for(drawy = 1; drawy<(ARRAYSIZE - 1); ++drawy)
is inside the first for's block.
Now for some reason, the x loop properly terminates at the final value of 9, while the y loop terminates at the value of 10. I.e. x completes 1-8, eight steps, while y does 1-9, nine steps. I could dump the whole shit into pastebin if anyone wants me to do that.
Name:
Anonymous2012-09-27 16:16
They both end at 10, but inside the scope you only see until 9, outside scope (after) you see them at 10 since the drawy symbol is defined in a more global scope.
Name:
Anonymous2012-09-27 16:19
>>2
Well they both should be ending at 9, since the whole (10-1) bit thing is part of the condition.
What do you mean by "more global"? I put int x; and int y; before the x loop.
Name:
Anonymous2012-09-27 16:24
hum you're right, maybe your code is changing their values mid-cycle, post a little code
The draw code is a bit of a clusterfuck, I do have a mistake or two in there (I'm trying to center a square grid), but otherwise, the for loop is pissing me right the fuck off.
Son of a bitch, the drawing loop was messed up. I'm retarded, I was drawing the squares 2 in height, which ended up making everything twice as long, which manifested as the last squares being twice as long vertically but the rest of the grid looking fine.
>>16
Except ++y is different to y++, particularly in the case of loops. Every textbook tries to make this point very clear, so I don't see why you don't seem to realise it.
>>17
Because I just kopipe'd his code and did some style modifications.
I didn't bother reading such an ugly piece of shit; I'm not sure if the pre-increment operator is vital or not for his code and I don't care because his style is shit.