SA-MP Forums Archive
array sizes do not match, or destination array is too small - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: array sizes do not match, or destination array is too small (/showthread.php?tid=512873)



array sizes do not match, or destination array is too small - nimagame - 13.05.2014

Hi .
I have a problem with my gamemode
If I compile this i get this errors :
C:\Users\Nima\Desktop\Sansor.pwn(26635) : error 047: array sizes do not match, or destination array is too small
C:\Users\Nima\Desktop\Sansor.pwn(26695) : error 047: array sizes do not match, or destination array is too small
C:\Users\Nima\Desktop\Sansor.pwn(2674 : error 047: array sizes do not match, or destination array is too small
C:\Users\Nima\Desktop\Sansor.pwn(27416) : error 047: array sizes do not match, or destination array is too small
C:\Users\Nima\Desktop\Sansor.pwn(27475) : error 047: array sizes do not match, or destination array is too small
C:\Users\Nima\Desktop\Sansor.pwn(28156) : error 047: array sizes do not match, or destination array is too small
C:\Users\Nima\Desktop\Sansor.pwn(28184) : error 047: array sizes do not match, or destination array is too small
C:\Users\Nima\Desktop\Sansor.pwn(28195) : error 047: array sizes do not match, or destination array is too small
C:\Users\Nima\Desktop\Sansor.pwn(28255) : error 047: array sizes do not match, or destination array is too small
C:\Users\Nima\Desktop\Sansor.pwn(28524) : error 047: array sizes do not match, or destination array is too small
C:\Users\Nima\Desktop\Sansor.pwn(28551) : error 047: array sizes do not match, or destination array is too small
C:\Users\Nima\Desktop\Sansor.pwn(28581) : error 047: array sizes do not match, or destination array is too small
C:\Users\Nima\Desktop\Sansor.pwn(28589) : error 047: array sizes do not match, or destination array is too small
C:\Users\Nima\Desktop\Sansor.pwn(28623) : error 047: array sizes do not match, or destination array is too small
C:\Users\Nima\Desktop\Sansor(28631) : error 047: array sizes do not match, or destination array is too small
C:\Users\Nima\Desktop\Sansor.pwn(28664) : error 047: array sizes do not match, or destination array is too small
C:\Users\Nima\Desktop\Sansor.pwn(28709) : error 047: array sizes do not match, or destination array is too small
C:\Users\Nima\Desktop\Sansor.pwn(28772) : error 047: array sizes do not match, or destination array is too small
C:\Users\Nima\Desktop\Sansor.pwn(28830) : error 047: array sizes do not match, or destination array is too small
C:\Users\Nima\Desktop\Sansor.pwn(2883 : error 047: array sizes do not match, or destination array is too small
C:\Users\Nima\Desktop\Sansor.pwn(28873) : error 047: array sizes do not match, or destination array is too small
C:\Users\Nima\Desktop\Sansor.pwn(28881) : error 047: array sizes do not match, or destination array is too small
C:\Users\Nima\Desktop\Sansor.pwn(2910 : error 047: array sizes do not match, or destination array is too small
C:\Users\Nima\Desktop\Sansor.pwn(29162) : error 047: array sizes do not match, or destination array is too small
C:\Users\Nima\Desktop\Sansor.pwn(29215) : error 047: array sizes do not match, or destination array is too small
C:\Users\Nima\Desktop\Sansor.pwn(29527) : error 047: array sizes do not match, or destination array is too small

Quote:

Line 26635

Код:
	cmd = strtok(cmdtext, idx);
Quote:

Line 26695

Код:
tmp = strtok(cmdtext, idx);
And More Line Like line 26695
Please Help Me
ty.
[And Sory For My Bad English]


Re: array sizes do not match, or destination array is too small - Mriss - 13.05.2014

Send the whole code please.


Re: array sizes do not match, or destination array is too small - nimagame - 13.05.2014

I Attach This Gamemode.


Re: array sizes do not match, or destination array is too small - Madd92 - 13.05.2014

If I may say this, please use the search function
=> array sizes do not match, or destination array is too small

It's completely the same problem. The answers suggest to use strrest instead of strtok:
Quote:
Originally Posted by smeti
Посмотреть сообщение
strtok original code new result[20]; <-- 20 cell
new tmp[128], tmp2[128], <-- 128 cell

array size do not match tmp(128 cell) not equal result (20 cell)

Use strrest in gl_common.inc.

pawn Код:
#include "../include/gl_common.inc"

//...

new tmp[128], tmp2[128], Index; tmp = strrest(params,Index), tmp2 = strrest(params,Index);
Quote:
Originally Posted by Vince
Посмотреть сообщение
Pretty sure strtok returns only 256 size strings. Yet another reason why you should abolish this method ASAP.
I hope this helps.


Re: array sizes do not match, or destination array is too small - nimagame - 13.05.2014

Can you fix it for me ?
I don't understand.
I Give you 2+ rip!


Re: array sizes do not match, or destination array is too small - Madd92 - 13.05.2014

Quote:
Originally Posted by nimagame
Посмотреть сообщение
Can you fix it for me ?
I don't understand.
I Give you 2+ rip!
Just use strrest instead of strtok. You have to include the function of course if you haven't already.
pawn Код:
#include "../include/gl_common.inc"
You can have a look at both functions >> here <<.
Then you also might be able to figure out the problem. Hint: 20 is smaller than 128, thus "the array sizes do not match".


Re: array sizes do not match, or destination array is too small - nimagame - 13.05.2014

I use strrest instead of strtok.
but again I get error array sizes do not match, or destination array is too small
And this errors :
../include/gl_common.inc(80) : error 021: symbol already defined: "strtok"
../include/gl_common.inc(139) : error 021: symbol already defined: "isNumeric"
../include/gl_common.inc(194) : error 021: symbol already defined: "ReturnUser"


Re: array sizes do not match, or destination array is too small - Madd92 - 13.05.2014

Ok then don't include the file and try just declaring the function:
pawn Код:
stock strrest(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }
    new offset = index;
    new result[128];
    while ((index < length) && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}
That should really work then, it does for me at least. As you can see, result in strrest has the same size as tmp and cmd.


Re: array sizes do not match, or destination array is too small - nimagame - 13.05.2014

I put it under the OnPlayerCommandText
And Again get errors :
Код:
C:\Users\Administrator\Desktop\Iranian RPG\gamemodes\larp.pwn(28271) : error 033: array must be indexed (variable "tmp")
C:\Users\Administrator\Desktop\Iranian RPG\gamemodes\larp.pwn(30197) : error 047: array sizes do not match, or destination array is too small
C:\Users\Administrator\Desktop\Iranian RPG\gamemodes\larp.pwn(30239) : error 047: array sizes do not match, or destination array is too small
C:\Users\Administrator\Desktop\Iranian RPG\gamemodes\larp.pwn(30294) : error 047: array sizes do not match, or destination array is too small
C:\Users\Administrator\Desktop\Iranian RPG\gamemodes\larp.pwn(30651) : error 047: array sizes do not match, or destination array is too small
C:\Users\Administrator\Desktop\Iranian RPG\gamemodes\larp.pwn(31043) : error 047: array sizes do not match, or destination array is too small
C:\Users\Administrator\Desktop\Iranian RPG\gamemodes\larp.pwn(32102) : error 047: array sizes do not match, or destination array is too small
C:\Users\Administrator\Desktop\Iranian RPG\gamemodes\larp.pwn(32298) : error 047: array sizes do not match, or destination array is too small
C:\Users\Administrator\Desktop\Iranian RPG\gamemodes\larp.pwn(32793) : error 047: array sizes do not match, or destination array is too small
C:\Users\Administrator\Desktop\Iranian RPG\gamemodes\larp.pwn(33659) : error 047: array sizes do not match, or destination array is too small
C:\Users\Administrator\Desktop\Iranian RPG\gamemodes\larp.pwn(34248) : error 047: array sizes do not match, or destination array is too small
C:\Users\Administrator\Desktop\Iranian RPG\gamemodes\larp.pwn(47692) : error 047: array sizes do not match, or destination array is too small
C:\Users\Administrator\Desktop\Iranian RPG\gamemodes\larp.pwn(62023) : error 047: array sizes do not match, or destination array is too small
C:\Users\Administrator\Desktop\Iranian RPG\gamemodes\larp.pwn(62125) : error 047: array sizes do not match, or destination array is too small
C:\Users\Administrator\Desktop\Iranian RPG\gamemodes\larp.pwn(62295) : error 047: array sizes do not match, or destination array is too small
C:\Users\Administrator\Desktop\Iranian RPG\gamemodes\larp.pwn(62531) : error 047: array sizes do not match, or destination array is too small
C:\Users\Administrator\Desktop\Iranian RPG\gamemodes\larp.pwn(62733) : error 047: array sizes do not match, or destination array is too small
C:\Users\Administrator\Desktop\Iranian RPG\gamemodes\larp.pwn(63349) : error 047: array sizes do not match, or destination array is too small
C:\Users\Administrator\Desktop\Iranian RPG\gamemodes\larp.pwn(63770) : error 047: array sizes do not match, or destination array is too small
C:\Users\Administrator\Desktop\Iranian RPG\gamemodes\larp.pwn(64106) : error 047: array sizes do not match, or destination array is too small
C:\Users\Administrator\Desktop\Iranian RPG\gamemodes\larp.pwn(64307) : error 047: array sizes do not match, or destination array is too small
C:\Users\Administrator\Desktop\Iranian RPG\gamemodes\larp.pwn(64562) : error 047: array sizes do not match, or destination array is too small
C:\Users\Administrator\Desktop\Iranian RPG\gamemodes\larp.pwn(64780) : error 047: array sizes do not match, or destination array is too small
C:\Users\Administrator\Desktop\Iranian RPG\gamemodes\larp.pwn(64926) : error 047: array sizes do not match, or destination array is too small
C:\Users\Administrator\Desktop\Iranian RPG\gamemodes\larp.pwn(65191) : error 047: array sizes do not match, or destination array is too small
C:\Users\Administrator\Desktop\Iranian RPG\gamemodes\larp.pwn(65233) : error 047: array sizes do not match, or destination array is too small



Re: array sizes do not match, or destination array is too small - nimagame - 13.05.2014

Anybody Can Help me ??