desktop wrote:
I am simulating a display that consists of 20x20 pixels. All pixels
are per default white but I would like to be able to turn on some or
all the pixels.
By "turn on" you mean make them black?
My idea was to create a 3 dimensional array:
in a[][][]
I believe you meant
int a[][][]
where the first index is the potential numbers of pixels that I would
like to paint (20x20). The following two index should be the
coordinates for the pixels that should be painted. If I want to paint
3 pixels (2,4), (17,9), (10,3) the following should be made:
a[0][2][4];
a[1][17][9];
a[2][10][3];
What's the meaning of [2]? What does it mean "shoudl be made"?
But when I declare a 3-dim array:
a[][][];
I get:
error: declaration of ?a? as multidimensional array must have bounds
for all dimensions except the first
Yes. Any array needs its size defined.
I have then tried:
a[20*20][20*20][20*20];
But is there not some way to accomplish my above 3 pixels without
making such a huge array?
Each pixel can be modelled by a single element in the array. That
means you need
char a[20][20] = {}; // initially zero
and if you want to set certain pixels to something, do
a[2][4] = 1;
a[17][9] = 1;
a[10][3] = 1;
(or any other non-zero value). You could even use 'bool', but then
if you suddenly want 255 levels of gray, you'd have to rewrite it.
V
loop to print/draw only 3 pixels.
extract the coordinate.