Hi while writing a bit more code for a little project i'm doing, (trying to teach myself c)
i wrote this:
Code:
#include <stdio.h>
int main()
{
int i, a;
for (i = 0; i <= 8; i++)
{
for (a = 0; a <= 8; i++)
printf("i = %d\n", i);
}
}
The output was a little unexpected:
Code:
...
i = 10388
i = 10389
i = 10390
i = 10391
i = 10392
i = 10393
i = 10394
i = 10395
i = 10396
i = 10397
i = 10398
i = 10399
i = 10400
i = 10401
i = 10402
i = 10403
i = 10404
i = 10405
i = 10406
i = 10407
i = 10408
i = 10409
i = 10410
i = 10411
i = 10412
i = 10413
i = 10414
i = 10415
i = 10416
i = 10417
i = 10418
i = 10419
i = 10420
i = 10421
i = 10422
i = 10423
i = 10424
i = 10425
i = 10426
i = 10427
i = 10428
i = 10429
...
And so on! I can't understand what i'm doing wrong as i thought the conditions in the for loop would keep it in check. Surely i shouldn't be more than 8? No?
Thanks in advance from a newb!
Simon