what exactly is string length?

mw mingwu at gmail.com
Fri Apr 2 05:02:52 UTC 2021


On Friday, 2 April 2021 at 04:54:07 UTC, Computermatronic wrote:
> On Friday, 2 April 2021 at 04:49:22 UTC, mw wrote:
>> So you mean inside the writeln() call, the 0s are skipped?
>>
>> Well, if I use `string t` as filename, it will try to looking 
>> for a file called:
>>
>> "head-abc\0\0\0-tail" instead of just "head-abc-tail" ?
>>
>> or it's platform dependent?
>
> I would imagine that it's platform dependant, but given most 
> platforms adhere to the C ABI, and C string are null 
> terminated, you'd end up looking for a file called "head-abc".

Ahh, I got what I see (from writeln) is not what get string here 
;-)

And I just tried:

string t = text("head-", strip(s), "-tail");

It's the same behavior.

So how can I trim the leading & trailing `\0` from the static 
char array?


More information about the Digitalmars-d-learn mailing list