what exactly is string length?
Виталий Фадеев
vital.fadeev at gmail.com
Fri Apr 2 05:25:53 UTC 2021
On Friday, 2 April 2021 at 04:32:53 UTC, mw wrote:
> https://run.dlang.io/is/B4jcno
>
> ---
> 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?
> }
> ---
>
> Why the last output is 16 instead of 13, t's type is string
> here.
Test this:
https://run.dlang.io/is/Cq4vjP
More information about the Digitalmars-d-learn
mailing list