I'm trying to write a program to 'simulate video feedback' so I've chosen to use some 2-dimensional arrays representing a screen/camera etc.
I've got a fairly good idea what I want to do but I keep messing up the loops I'm trying to use and I'm starting to go crazy!
I have a 3x3 array called 'pixel1' that represents a pixel on the screen and I want to fill the 'screen' array with 'pixels'. I'm using some nested for loops for this but every time I've tried, although the code compiles and builds fine, it won't run. I keep getting 'unhandled win32 exception'/'stack overflow' so I think I'm probably calling an array element that doesn't exist but I can't figure out where!
The screen array has 960 columns and 720 rows, the pixels are 3x3 (meaning the screen is 320x240 pixels)
The first one seems ok. I'm not sure about the second one...
Anyway, stack overflow usually occurs when recursion is used, or maybe when you try to allocate really a lot of memory. I can't see why would this cause such error. If you remove these lines, does the error remain?
By the way, don't you think that using i++ would be quicker that i=i+1 ?
Thanks for the advice! I tried taking everything out of the code apart from the declaration of the arrays. Turns out if I make the 'screen' array a lot smaller I don't get any error but if I leave it the same size the error's still there. How can I get round this problem since I really need to use a large 2D array?
And I'm a total newbie at C++ so I didn't realise you could use expressions like i++, thanks for the tip!