array sizes do not match?
#1

Well i get these 2 errors when compiling,

pawn Код:
array sizes do not match, or destination array is too small
 array sizes do not match, or destination array is too small
And these are both the lines i use
pawn Код:
tmp = strtok(params, index);

    tmp2 = strtok(params, index);
You know whats wrong? or maybe can help me?
Reply
#2

index is too small? did you do something like this? new index[1]; ? Make it bigger. (I'm guessing)
Reply
#3

Quote:
Originally Posted by Retardedwolf
Посмотреть сообщение
index is too small? did you do something like this? new index[1]; ? Make it bigger. (I'm guessing)
This is what i got.

pawn Код:
new tmp[30],
        tmp2[30],
        index;
Reply
#4

tmp and tmp2 need to be bigger, I don't know what the limit for strtok is but it has a lowest one
Reply
#5

Quote:
Originally Posted by Lenny the Cup
Посмотреть сообщение
tmp and tmp2 need to be bigger, I don't know what the limit for strtok is but it has a lowest one
tried changing the limit, still get the same error. :/
Reply
#6

strtok returns a string of a fixed size. You get the error because strtok is returning a string bigger than 30 cells long, it's like trying to put an airplane in your garage designed to hold only your car. It just won't work, there's not enough space.

If you increase the size of tmp and tmp2 to a size bigger than or the same size as the array returned in strtok (look at the function code, try search for the array named 'result') then that will get rid of your error. I cannot tell you the exact number because it changes from script to script... some numbers if you can't find the right size are 128 and 256.

I would recommend ditching strtok and using sscanf. It's faster, won't cry about array sizes and is a lot more flexible.
Reply
#7

Fixed itby making the size of the tmp, tmp2, to 480.

Thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)