On Thursday, 30 December 2021 at 09:34:27 UTC, eugene wrote:

```d
char[] s = cast(char[])ioCtx.buf[0 .. strlen(cast(char*)ioCtx.buf.ptr) - 1];
// -1 is to eliminate terminating '\n'
writefln("got '%s' from '%s:%d'", s, client.addr, client.port);
```

Is there some more concise/elegant way to do that?

Try `auto s = fromStringz(cast(char*)ioCtx.buf.ptr)`.


          • Re: print ub... eugene via Digitalmars-d-learn
            • Re: pri... H. S. Teoh via Digitalmars-d-learn
            • Re: pri... eugene via Digitalmars-d-learn
            • Re: pri... eugene via Digitalmars-d-learn
              • Re:... Adam D Ruppe via Digitalmars-d-learn
              • Re:... eugene via Digitalmars-d-learn
            • Re: pri... Steven Schveighoffer via Digitalmars-d-learn
              • Re:... eugene via Digitalmars-d-learn
              • Re:... frame via Digitalmars-d-learn
              • Re:... Steven Schveighoffer via Digitalmars-d-learn
  • Re: print ubyte[] as (ascii) ... Dukc via Digitalmars-d-learn

Reply via email to