On Monday, 22 June 2020 at 09:06:35 UTC, Jacob Carlborg wrote:

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

OK, it makes sense that the null terminator would be added where compatability with C is required.

Good to know.

Reply via email to