Sizeof 2D Array
#1

Hello there,

I have this array:

pawn Код:
enum _robinfos{
    rName[64],
    rPay,
    Float:rX,
    Float:rY,
    Float:rZ,
    rID
}

new RobInfos[6][100][_robinfos];
And when I want to get size of RobInfos[1] I do this
pawn Код:
sizeof(RobInfos[1])
but from some reason I get this error
Код:
D:\Roleplay\gamemodes\Robbers Stylez.pwn(172) : error 001: expected token: "]", but found "-integer value-"
D:\Roleplay\gamemodes\Robbers Stylez.pwn(172) : warning 215: expression has no effect

4 Errors.
D:\Roleplay\gamemodes\Robbers Stylez.pwn(172) : error 001: expected token: ";", but found "]"
D:\Roleplay\gamemodes\Robbers Stylez.pwn(172) : error 029: invalid expression, assumed zero
D:\Roleplay\gamemodes\Robbers Stylez.pwn(172) : fatal error 107: too many error messages on one line
can anyone tell me what am I doing wrong here...
Reply
#2

Read what the compiler says:
Код:
error 001: expected token: "]", but found "-integer value-"
Reply
#3

and? if you see the code there is no open [ left, its sizeof(RobInfos[1]); that means size of sub arrays in one array
Reply
#4

Remove the value.
Reply
#5

Well I can't, I have RobInfo[6][100][_some_enum], and I need to get all records from RobInfo[6] but if I change RobInfo[6][100][_some_enum] to RobInfo[6][][_some_enum] it crashes compiler.
Reply
#6

What part of the array do you actually want the size of? This is btw an 3D array, not 2D
Reply
#7

try this...
sizeof(RobInfos[])
Reply
#8

Quote:
Originally Posted by mastermax7777
Посмотреть сообщение
try this...
sizeof(RobInfos[])
That would get the size of the 2nd dimension. What he (apparently) wants to do is getting the size of the string inside the enum. My best shot would be either
pawn Код:
sizeof( RobInfos[][] )
or
pawn Код:
sizeof( RobInfos[][][] )
Reply
#9

Quote:
Originally Posted by LarzI
Посмотреть сообщение
That would get the size of the 2nd dimension. What he (apparently) wants to do is getting the size of the string inside the enum. My best shot would be either
pawn Код:
sizeof( RobInfos[][] )
or
pawn Код:
sizeof( RobInfos[][][] )
[][][] is not valid, thats 4. he probably wants what i posted before
Reply
#10

- ignore -
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)