Strings- Error
#1

Hey , please check the following example:
pawn Код:
new string[4][128];
format(string[0], sizeof(string[0]), "BlaBla%i", int);
when I do this I get an error
so I have to change the sizeofstring(string[0]) to 128 to get rid of the error
pawn Код:
new string[4][128];
format(string[0], 128, "BlaBla%i", int);
this works fine
Why?
Reply
#2

do it like this
pawn Код:
new string[4][128];
    format(string[0], sizeof(string), "BlaBla%i", int);
just "sizeof(string)" without the brackets is enough cuz
the sole name of an array is the pointer to it's 1st element

ps: u don't need the clips when using the keyword "sizeof"
this:
pawn Код:
format(string[0], sizeof string, "BlaBla%i", int);
works fine too
Reply
#3

pawn Код:
sizeof(string) returns 4
pawn Код:
sizeof(string[]) returns 128
Reply
#4

Quote:
Originally Posted by Jefff
Посмотреть сообщение
pawn Код:
sizeof(string) returns 4
pawn Код:
sizeof(string[]) returns 128
Thanks, that's it, +rep

-----------

Quote:
Originally Posted by CutX
Посмотреть сообщение
do it like this
pawn Код:
new string[4][128];
    format(string[0], sizeof(string), "BlaBla%i", int);
just "sizeof(string)" without the brackets is enough cuz
the sole name of an array is the pointer to it's 1st element

ps: u don't need the clips when using the keyword "sizeof"
this:
pawn Код:
format(string[0], sizeof string, "BlaBla%i", int);
works fine too
thanks, but the right one is sizeof string[], +rep also since I learned that I don't need the "()"

__________________________________________________ __________________________________________________ _______________________________________________

One last question,
now in this case
pawn Код:
new string[4][128];
I can use sizeof string[]
but what do I do in this case
pawn Код:
enum pData
{
    pPass[20], // what do I do to get the size of this one?
        // .....
    pCash,
    Float:pPosx,
    Float:pPosy,
    Float:pPosz,
    pKills,
    pDeaths,
    pVehnumber,
    Float:pHealth
}
new PlayerData[MAX_PLAYERS][pData];
I don't believe that I can simply use sizeof PlayerData[][] for the size of pPass which is 20
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)