13.10.2018, 22:42
Why is this happening? I have not found any solution for this.
warning 224: indeterminate array size in "sizeof" expression (symbol "maxlength")
PHP Code:
CMD:test(playerid, params[])
{
new text[90];
if(sscanf(params, "s[90]", text)) return SendClientMessage(playerid,-1, "/test (text)");
TestText(text);
new str[90]; format(str, sizeof(str), "%s", text);
SendClientMessageToAll(-1, str);
return 1;
}
TestText(text[])
{
strreplace(text, "test_01", "replace_01");
strreplace(text, "test_02", "replace_02");
return 1;
}
PHP Code:
strreplace(string[], const search[], const replacement[], bool:ignorecase = false, pos = 0, limit = -1, maxlength = sizeof(string))
{
if(limit == 0)
return 0;
new sublen = strlen(search),
replen = strlen(replacement),
bool:packed = ispacked(string),
maxlen = maxlength,
len = strlen(string),
count = 0;
if(packed)
maxlen *= 4;
if(!sublen)
return 0;
while(-1 != (pos = strfind(string, search, ignorecase, pos)))
{
strdel(string, pos, pos + sublen);
len -= sublen;
if(replen && len + replen < maxlen){
strins(string, replacement, pos, maxlength);
pos += replen;
len += replen;
}
if(limit != -1 && ++count >= limit)
break;
}
return count;
}