30.08.2012, 08:10
Quote:
strcount will an infinity loop, here is the fix:
Код:
stock strcount(const text[], const find[], bool:ignorecase = false) { new pos = 0 - strlen(find), found = 0; while(-1 != (pos = strfind(text, find, ignorecase, pos + strlen(find)))) found++; return found; } |
pawn Код:
printf("%d", strcount("abcabcabc", "abcabc"));
// output: 1
printf("%d", strcount("abcabcabc", "abcabc", .count_overlapped = true));
// output: 2