[Ajuda] Separar strings - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: Non-English (
https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (
https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (
https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda] Separar strings (
/showthread.php?tid=660646)
Separar strings -
B4dSh33p - 09.11.2018
Eu estou tentando colocar 3 caracter de uma string em uma variбvel inteiro mais nгo estou conseguindo, o resultado que eu queria era:
int[0] = 666;
int[1] = 666;
mas nгo estou conseguindo. o cуdigo que estou tentando criar й esse.
PHP код:
new string[28],int[32],unPOS;
string = "666|666|666|666|666|666|666";
for(new s; s < 32; s++)
{
for(new i; i < sizeof(string); i++)
{
unPOS = strfind(string, "|", false);
//string2[s] = string[unPOS];
string[s] = string[unPOS];
format(string2[s], unPOS,"%s",string);
}
}
eu coloquei o " | " como uma forma de filtrar, porque entre eles terгo diferentes valores, e eu queria apenas os 3.
Re: Separar strings -
Electrifying - 09.11.2018
https://sampwiki.blast.hk/wiki/Strval
Re: Separar strings -
ipsLuan - 09.11.2018
Tente com
split.
Re: Separar strings -
Paulthaz - 09.11.2018
Vc pode fazer isso com o sscanf tbm
Код:
new string[28], valores[7];
string = "666|666|666|666|666|666|666";
sscanf(string, "p<|>a<d>[7]", valores);
for(new i; i < sizeof(valores); i ++)
{
printf("valor%d=%d", i+1, valores[i]);
}
Re: Separar strings -
B4dSh33p - 11.11.2018
Quote:
Originally Posted by Paulthaz
Vc pode fazer isso com o sscanf tbm
|
Reputado e Obrigado. vou dб uma olhada nessa sscanf ele й mais importante do que eu pensei.