18.05.2020, 05:26
A poorly coded number checker, what does it do?
It gets me the number written in a string firstly. like Stringab12cd456gh returns 12 !
i wanted it in some process so did this shit:
like:
prints 12.
It gets me the number written in a string firstly. like Stringab12cd456gh returns 12 !
i wanted it in some process so did this shit:
like:
PHP Code:
printf("ANDEBUG: %i", GetNumberFromString("ezpz12r3"));
PHP Code:
GetNumberFromString(string[])
{
new str[10], cnt = -1, tmps[2];
for(new i = 0, len = strlen(string); i < len; i++)
{
if(isNumber(string, i) && cnt == -1)
{
format(tmps, 2, string[i]);
strcat(str, tmps);
cnt = i;
}
if(isNumber(string, i) && cnt == i-1)
{
format(tmps, 2, string[i]);
strcat(str, tmps);
cnt = i;
}
}
new intt;
intt = strval(str);
return intt;
}
isNumber(c[], index)
{
switch(c[index])
{
case '0' .. '9': return true;
default: return false;
}
return false;
}