Some questions about strings

Jacob Carlborg doob at me.com
Mon Jun 22 09:06:35 UTC 2020


On Monday, 22 June 2020 at 04:08:10 UTC, Denis wrote:

> The terminating null character was one of the reasons I thought 
> strings were different from char arrays. Now I know better.

String **literals** have a terminating null character, to help 
with integrating with C functions. But this null character will 
disappear when manipulating strings.

You cannot assume that a function parameter of type `string` will 
have a terminating null character, but calling `printf` with a 
string literal is fine:

printf("foobar\n"); // this will work since string literals have 
have a terminating null character

--
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list