tri-dimension Array alternatives
Hi All,
I am looking at options for holding multiple sets of 3 elements of data to represent a 'Starry Background' (x and y co-ordinates and a colour value - all integers).
I was fine with an Array for x and y (int stararry[600][1]) prior to adding the colour component.
I could use a tri-dimensional Array but that could use a ton of memory.
I could use 3 seperate Arrays (each [600]). One for x, one for y and one for colour.
Idea's?
Cheers,
Re: tri-dimension Array alternatives
Ok, possibly a Structure?
Code:
typedef struct starAtributes
{
int x, y, colour;
} starAtributes;
starAtributes stars[600];
Re: tri-dimension Array alternatives
What makes you think it'll use less memory just because you use a different way of denoting the exact same structure? As long as you have 600 stars, and each star has a x, y and color components, and each of these components is 4 bytes large, you'll use 7200 bytes of memory - which is not that much, btw.
Re: tri-dimension Array alternatives
My concern was with the tri-state Array. Since then I realised I could use a structure.
I now see that the two will consume the same amount of memory. :)
The structure (stars) is easier to use too.
Cheers,