2d array memory use (quiz question)

how do you figure how many bytes a array of float arr[8],[8] uses this was a question i can not find the formula or answer to , I thought you times the 8*8*
4 (bytes per float ) but that is not right. Some help on how to figure memory used on this array of floats would be greatly appreciated.
The sizeof operator is your friend ;-)
yeah i used that to find the answer but is there a math formula based on the size of the array with the type used (float, int, char) ?
Yes, arrays are tightly packed, which means you can use the formula you originally thought - 8 * 8 * 4, but that's assuming a 4-byte float, which isn't necessarily the case.

The formula you want for an array float arr[8][8] is 8 * 8 * sizeof(float)

But sizeof(arr) is best ;-)

Thanks that what i was doing but must have fat finger the calculator and got the wrong answer. Perfect that is what i was looking for.
Topic archived. No new replies allowed.