I need to store the integar values of a screen(1280x1024)into an array,but the array must be 6244 elements long.
I checked its sizeof and its 2293672 bytes big,2293kb.
This sounds absurd or maybe its not so absurd,can anyone tell be if this is unrealistic programming and i should find another way.

04-07-2007

Kurgusov

My first post here is obscure and misleading,so Ill explain better,and if I get any replys Ill be a bit surprised and the glory will be all yours.

what Ive done is made a 2d array[48][128] which is the size of the screen,and that array[48][128] will be filled with integars that refer to a description of a room,(so pc moves into x13,y13 which holds the value of 3,which will give the description of a small passage).

The value of each element of the 2d array is randomly made by a rand function that needs to have an array 6244 elements long so it can assign a value to all the 2d array elements.

dice[6244] is that single dimensional array in question,it would hold that many random numbers and assign them to 2d array[48][128].

dice[6244] when initialised takes 2293672 bytes of space,my question is,is that a bad thing for an application where speed isn't an issue.
It sounds like a lot of space for one array to have.

04-07-2007

laserlight

Are you sure of the size? If it is an array of int, then I believe the size would be 6244 * 4 = 24976 bytes, assuming sizeof(int) is 4 bytes.

2293672 / 6244 is about 367.34, and I find it odd that each element in the array would have a non-integral number of bytes.

EDIT:
Oh, and 48 * 128 = 6144
So, if you need 6144 ints, and sizeof(int) is 4, then your array would be 6144 * 4 = 24576 bytes = 24 KiB.
Even if sizeof(int) = 8, your array would only be 48 KiB, a far cry from the 2.1 MiB that you propose it takes up.

04-07-2007

Kurgusov

thx laserlight,yeah,2144...
just one question,do you or anyone here think an array of 6144 elements is bad programing,or is it normal?