what exactly is string length?

rikki cattermole rikki at cattermole.co.nz
Fri Apr 2 04:36:01 UTC 2021


On 02/04/2021 5:32 PM, mw wrote:
> ---
> import std;
> import std.conv : text;
> 
> 
> void main()
> {
>     char[6] s;
>     s = "abc";
>     writeln(s, s.length);  // abc6, ok it's the static array's length
> 
>     string t = text("head-", s, "-tail");
>     writeln(t, t.length);  // head-abc-tail16, why?
assert(t[9] == '\0');
> }
> ---



More information about the Digitalmars-d-learn mailing list