-
todays how do i question
I have the following
Code:
unsigned Factors[4] = { 0 }, Answer[4][4] = { { 0 } };
const unsigned FacSize = sizeof Factors / sizeof *Factors,
AnsSize = sizeof Answer / sizeof **Answer;
facsize is 4 as it should be as its a single array however, AnsSize is 16. Whilst i agree that 4 *4 = 16 and i can see why i get that it is kind of meaningless as it could describe the following
Code:
array[16]
or
array[2][8]
is there away of getting just the number of the second elements
-
I guess you have to do this as well.
AnsRowSize = sizeof Answer / sizeof *Answer;
So you can figure out the underlying dimensions.
-
I assume that i then divide AnsSize by AnsRowSize if thats the case can i not do this
Code:
AnsSize = sizeof **Answer / sizeof *Answer
or even the other way round as i assume **Answer is smaller than *Answer
-
Try some stuff, see what you get.
-
im still scared of it. However, i did find that with the following
Code:
int a[2][5], b[3][6], c[4][2];
int aSize = sizeof *a / **a, bSize = *b / **b, cSize = *c / **c;
printf("%d, %d, %d\n", aSize, bSize, cSize);
gave me an output of 5, 6, 2
so i assume that is correct.