error 047: 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: error 047: array sizes do not match, or destination array is too small (
/showthread.php?tid=249453)
error 047: array sizes do not match, or destination array is too small -
ShawnMiller1337 - 18.04.2011
Код:
error 047: array sizes do not match, or destination array is too small
Errors on this line:
Код:
Reports[MAX_REPORTS-1] = string;
Other stuff may needed
Код:
for(new i = 1; i < MAX_REPORTS; i++) Reports[i] = "<none>";
for(new i = 1; i < MAX_REPORTS; i++)
new Reports[MAX_REPORTS][128];
#define MAX_REPORTS 9
Re: error 047: array sizes do not match, or destination array is too small - [L3th4l] - 18.04.2011
pawn Код:
format(Reports[MAX_REPORTS-1], 128, "%s", string);
Re: error 047: array sizes do not match, or destination array is too small -
JaTochNietDan - 18.04.2011
What is the size of string?
Re: error 047: array sizes do not match, or destination array is too small -
admantis - 18.04.2011
Sorry, I said something wrong and I didn't think about it before posting.
Re: error 047: array sizes do not match, or destination array is too small -
JaTochNietDan - 18.04.2011
Quote:
Originally Posted by admantis
It is because..
pawn Код:
Reports[MAX_REPORTS-1] = string; /* This is a 'dinamic string size', and will return 'array sizes don't match' because MAX_REPORTS is defined as 9. 9-1 = 8, and 8 != 9.
Since the specified size would be 8 and MAX_REPORTS is 9, the sizes don't match, gives that error.*/
Got the spin? I am not sure if I explained good, or what I said is true, just guessing.
Use format() or [L3th4L]'s solution.
It is MAX_REPORTS(9)-1 (which is 8 )
|
Where did you get that from? I don't see it in any of the code he posted. Also I'm not sure I understand you either, I've compiled this just fine:
pawn Код:
#include <a_samp>
#define MAX_REPORTS 9
new Reports[MAX_REPORTS][128];
new string[128];
main()
{
Reports[MAX_REPORTS - 1] = string;
}
Re: error 047: array sizes do not match, or destination array is too small -
admantis - 18.04.2011
Quote:
Originally Posted by JaTochNietDan
Where did you get that from? I don't see it in any of the code he posted. Also I'm not sure I understand you either, I've compiled this just fine:
pawn Код:
#include <a_samp>
#define MAX_REPORTS 9
new Reports[MAX_REPORTS][128]; new string[128];
main() { Reports[MAX_REPORTS - 1] = string; }
|
Oh my god, I'm so sorry, a terrible twist in my head!
I misread