Help me about array
#1

I'm having a problem

Код:
new Skin[] =
{
         1, 2, 4, 8, 9, 10, 11, 60, 91,
         92, 93, 94, 95, 96, 97, 98, 99,
         138, 140
};

CMD:checksizeof(playerid, params[])
{
         new string[128];
         format(string, sizeof(string), "Sizeof Skin: %d", sizeof(Skin[]));
         SendClientMessage(playerid, -1, string);
         return 1;
}
I get a return value of 1 (Sizeof Skin: 1) while sizeof must be 19 (Sizeof Skin: 19)
Reply
#2

Код:
CMD:checksizeof(playerid, params[])
{
         new string[128];
         format(string, sizeof(string), "Sizeof Skin: %d", sizeof(Skin));
         SendClientMessage(playerid, -1, string);
         return 1;
}
Reply
#3

18 cells is enough you dont need 128
Reply
#4

You have one dimension array, so you don't need to use the square brackets in the sizeof operator. I also recommend that you use a 'static const' array to get the size of the string.

pawn Код:
CMD:foo(playerid, params[])
{
    static const fmt[] = "Sizeof skin: %d";
    new buffer[sizeof(fmt) + (-2 /* %d */ + 3 /*000*/ )];
    format(buffer, sizeof(buffer), fmt, sizeof(Skin));
    SendClientMessage(playerid, -1, buffer);
    return 1;
}
Reply
#5

Thank All
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)