|
1 registered members (TipmyPip),
18,546
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Array size
[Re: Joozey]
#170867
12/04/07 09:52
12/04/07 09:52
|
Joined: Jan 2007
Posts: 221
Fenriswolf
OP
Member
|
OP
Member
Joined: Jan 2007
Posts: 221
|
Hi, Quote:
What do you mean with size, amount of indexes?
Yes, I've meant the number of elements.
Quote:
Then what are you trying to achieve with sizeof(my_array[0])?
I wanted to calculate the size of a single array element in bytes. Dividing the array size in bytes by the element size in bytes should result the array's length in elements, if I'm not mistaken. If arrays are handled as pointers this would not work, though.
Your code works fine, thank you! However, the last element of the array has to be NULL; otherwise a wrong value is returned:
var my_array[3] = { 1, 2 } // works var my_array[3] = { 1, 2, 3 } // does not work
|
|
|
|
|
|