Mail Archives: djgpp/1999/10/06/06:46:07
nicblais AT my-deja DOT com writes:
> unsigned int matrix[res_x][res_y];
Depending on how big res_x and res_y are, this might be
overflowing your stack: there is only limited space for
local variables, so it would be better to use dynamic
allocation (ie. malloc) for any big arrays.
> pix_x = (random() % res_x) + 1;
This is a potential array overflow: C arrays count from
zero, so you don't want that + 1 on the end.
Also, you didn't initialise your array to anything, so
the starting contents are random. You need to fill it
with zeros before you can sensibly check for whether
values are set or not.
Shawn Hargreaves.
- Raw text -