31.08.2012, 07:43
sscanf (with "p<|>s[16]s[16]s[16]").
Without sscanf:
Untested, but you should get the idea.
`e: First bit only:
Without sscanf:
pawn Код:
stock getDatItem(itemPos) {
new str[64] = "Name_here | Pancakes | $12351", len = strlen(str), pipecount = 0, start = -1, stop = -1;
new res[16];
for(new i = 0; i < len; ++i) {
if('|' == str[i]) {
if(pipecount == itemPos) start = i;
pipecount++;
if(start != -1) {
stop = i;
break;
}
}
}
if(start != -1) {
if(stop == -1) stop = len - 1 - start;
strmid(res, str, start, stop);
}
return res;
}
`e: First bit only:
pawn Код:
stock getDatItem() {
new str[64] = "Name_here | Pancakes | $12351", i = 0, res[25];
while('\0' != str[i]) {
if('|' == str[i]) {
strmid(res, str, 0, i - 1);
break;
}
++i;
}
return res;
}