[Ajuda] Strsplit
#6

Tem uma stock que poderia ajudar:

Funciona similarmente ao strtok, exceto por que isso divide a string toda.

Parвmetros
strsrc: String para dividir..
strdest: Uma array 2D; Para armazenar os pedaзos divididos.
delimiter: Um caractere ou sнmbolo para identificar o inнcio e o fim da substring

pawn Код:
// Author unknown. It was probably someone smart like [[User:DracoBlue|DracoBlue]] or [[User:******|******]].
stock split(const strsrc[], strdest[][], delimiter)
{
    new i, li;
    new aNum;
    new len;
    while(i <= strlen(strsrc))
    {
        if(strsrc[i] == delimiter || i == strlen(strsrc))
        {
            len = strmid(strdest[aNum], strsrc, li, i, 128);
            strdest[aNum][len] = 0;
            li = i+1;
            aNum++;
        }
        i++;
    }
    return 1;
}
Exemplo:

pawn Код:
public OnFilterScriptInit()
{
    new tmp[2][128];
    split("Hello World!", tmp, ' ');
    print(tmp[0]);
}
Serб imprimido: Hello.

https://sampwiki.blast.hk/wiki/Code_Snippets#Split
Reply


Messages In This Thread
[Ajuda] Strsplit - by Macintosh - 19.09.2011, 03:03
Re: [Ajuda] Strsplit - by Falcon. - 19.09.2011, 11:55
Re: [Ajuda] Strsplit - by WLSF - 19.09.2011, 11:56
Re: [Ajuda] Strsplit - by Falcon. - 19.09.2011, 12:00
Re: [Ajuda] Strsplit - by WLSF - 19.09.2011, 12:02
Re: [Ajuda] Strsplit - by Shelby - 19.09.2011, 12:03
Re: [Ajuda] Strsplit - by Macintosh - 19.09.2011, 13:16
Re: [Ajuda] Strsplit - by [O.z]Caroline - 19.09.2011, 14:32

Forum Jump:


Users browsing this thread: 1 Guest(s)