new var1[][110] = "Text1\nText2\nText3", var2[][110], var3 = 0;
for(new str = 0; str2 <= strlen(var1); str < str2; str++)
{
if(var1[str] == "\n")
{
var2[var3++] = var1[str - 1];
}
}
new
originalString[] = "Text1\nText2\nText3";
new
posStart = -1,
posEnd = 0,
index = 0,
destination[5][110]; // maximum 5 splits
new i;
while(originalString[i++] && index < sizeof(destination)) // loop original string until end or until destination is full
{
// found linefeed
if(originalString[i] == '\n' || originalString[i] == EOS)
{
if(posStart < posEnd)
{
posStart = i;
}
else
{
posEnd = i;
}
if(posEnd > posStart)
{
strmid(destination[index], originalString, posStart, posEnd, sizeof(destination[]));
index++;
}
}
}
|
I'd try something like this. Not tested, but if my brain analyzed it correctly it should work.
PHP код:
|
new splitted[3][110];
new text[] = "Text1\nText2\nText3";
sscanf(text,"p<\n>s[110]s[110]s[110]",splitted[0],splitted[1],splitted[2]);
pawn Код:
pawn Код:
pawn Код:
When used with strings, the collection behaviour is overruled. Most specifiers are still space delimited, so for example this will work: pawn Код:
pawn Код:
pawn Код:
Код:
hello there 27 pawn Код:
|
new text[] = "Text1\nText2\nText3\nText4", parts[50][110];
sscanf(text, "p<\n>a<s[110]>[50]", parts);
for(new i = 0, j = sizeof(parts); i < j && parts[i][0] != EOS; i ++)
{
printf("%s", parts[i]);
}