error 047: array sizes do not match, or destination array is too small
#1

Код:
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
Reply
#2

pawn Код:
format(Reports[MAX_REPORTS-1], 128, "%s", string);
Reply
#3

What is the size of string?
Reply
#4

Sorry, I said something wrong and I didn't think about it before posting.
Reply
#5

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;
}
Reply
#6

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)