AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   sizeof() multi-dimensional arrays (https://forums.alliedmods.net/showthread.php?t=171508)

Diegorkable 11-06-2011 18:32

sizeof() multi-dimensional arrays
 
Hey guys,

im confused about something and i want to understand something that is wierd to me now.

Lets say I declared a multi-dimensional array:

PHP Code:

new variable[100][500

Now, I want to know the length of each array in the arrays (like, there is an array of arrays, and I want to know the length of each array in the array of arrays, which is 500)

From what I know, I should do it like this:

PHP Code:

sizeof(variable[0]) 

But I get compiler errors, and I can only do:

PHP Code:

sizeof(variable

Why is that? I try to think but it's confusing, I mean, sizeof(variable) isnt supposed to give me the length of the array of arrays? which is 100. but what do i do to get the returned value of 500? (the size of each array within the array of the arrays)

Arkshine 11-06-2011 18:35

Re: sizeof() multi-dimensional arrays
 
sizeof(variable[])

Emp` 11-06-2011 18:49

Re: sizeof() multi-dimensional arrays
 
And if you have a three dimensional array:

sizeof( variable[][] )

Diegorkable 11-06-2011 20:29

Re: sizeof() multi-dimensional arrays
 
Thank you.


All times are GMT -4. The time now is 14:18.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.