SA-MP Forums Archive
Symbol count in string - 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: Symbol count in string (/showthread.php?tid=423393)



Symbol count in string - dusk - 17.03.2013

Hello,how do I count how many letters and numbers ar there in a string?For example.

format(string,sizeof(string)"Hello 2 u"); There are 9symbols (inluding spaces). And how do I auto find it? Is there some function for that?


Re: Symbol count in string - AndreT - 17.03.2013

In runtime code, you can find the amount of characters in a string using the strlen function, which I assume you already know. How this function works is it iterates through the string until it discovers a terminating character (aka the null character), then returns the iterator value.

But if you're asking on how to evaluate it prior to compilation, I think you'd be good off using an advanced text editor such as Notepad++ which will display the amount of characters highlighted on the bottom of your editor window.