what exactly is string length?
H. S. Teoh
hsteoh at quickfur.ath.cx
Fri Apr 2 05:20:48 UTC 2021
On Fri, Apr 02, 2021 at 05:05:21AM +0000, mw via Digitalmars-d-learn wrote:
[...]
> This is just an example, what if the exact length is not known
> statically, is there a functions to trim the `\0`s?
Another way, if you want to avoid the extra allocation, slice the static
array with .indexOf:
s[0 .. s.indexOf('\0')]
should give you the initial segment up to the first null.
T
--
Questions are the beginning of intelligence, but the fear of God is the beginning of wisdom.
More information about the Digitalmars-d-learn
mailing list