www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Null terminated character

reply vc <dandondendinmpum gmail.com> writes:
I've try this '\0'*10 and didn't work, i want the results be 
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
Jun 23 2022
next sibling parent reply frame <frame86 live.com> writes:
On Thursday, 23 June 2022 at 16:16:26 UTC, vc wrote:
 I've try this '\0'*10 and didn't work, i want the results be 
 \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
One way: ```d import std.range; repeat("\0", 10).join(""); ```
Jun 23 2022
parent frame <frame86 live.com> writes:
On Thursday, 23 June 2022 at 17:27:51 UTC, frame wrote:
 On Thursday, 23 June 2022 at 16:16:26 UTC, vc wrote:
 I've try this '\0'*10 and didn't work, i want the results be 
 \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
One way: ```d import std.range; repeat("\0", 10).join(""); ```
If you just need an array: ```d char[] n; n.length = 10; n[] = '\0'; ```
Jun 23 2022
prev sibling parent Bastiaan Veelo <Bastiaan Veelo.net> writes:
On Thursday, 23 June 2022 at 16:16:26 UTC, vc wrote:
 I've try this '\0'*10 and didn't work, i want the results be 
 \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
```d string nulls = '\0'.repeat(10).array; ``` — Bastiaan.
Jul 02 2022