How to print or check if a string is "\0" (null) terminated in the D programming language?

Andrea Fontana nospam at example.com
Wed Apr 6 09:47:36 UTC 2022


On Wednesday, 6 April 2022 at 08:55:43 UTC, BoQsc wrote:
> I have a feeling that some parts of my code contains 
> unterminated strings and they do overflow into other string 
> that is to be combined. I'd like to take a look at strings, 
> analyse them manually and see if any of them end up terminated 
> or not.
>
> Please provide any relevant examples of how you do this.

string literals are zero-terminated in d.

If you need to pass a D string to a C function use toStringz()
https://dlang.org/library/std/string/to_stringz.html




More information about the Digitalmars-d-learn mailing list