SA-MP Forums Archive
Quesiton: things - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Quesiton: things (/showthread.php?tid=424029)



Quesiton: things - XStormiest - 20.03.2013

I have a question ,exist something that calculate the characters in a string?
for example i say

"Maria have apple"

are 5 +space+ 4 +space + 5 = 16 characters in this string is new string[17];
and my question is: is a thing that auto-calculate the number of char in a string?


Re: Quesiton: things - Misiur - 20.03.2013

pawn Код:
stock Numchars(str[]) {
    new num;
    for(new i = 0, j = strlen(str); i != j; ++i) {
        if(' ' != str[i]) ++num;
    }
    return num;
}



Re: Quesiton: things - XStormiest - 20.03.2013

ok ths


Re: Quesiton: things - SuperViper - 20.03.2013

Or you can just use the native function strlen which Misiur used in his alternative Numchars function....


Re: Quesiton: things - Misiur - 20.03.2013

Oh lawd, sorry OP, I thought you wanted count of real characters excluding spaces. Of course SuperViper is right, strlen is what you are looking for