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.

Reply via email to