Cannot implicitly convert expression (&sbuf) of type char [1024] to IOREQ *

Nicholas Wilson via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Nov 29 15:41:48 PST 2016


On Tuesday, 29 November 2016 at 23:33:19 UTC, Ali Çehreli wrote:
> On 11/29/2016 07:30 AM, Anders S wrote:
>
> >     INT    argv[1];        /* list of arguments */
>

Speculation, but given that you say "list of args" is it possible 
OP means to use int[0] for an inline array.

> In addition to what Nemanja Boric wrote, the recommended array 
> syntax in D is the following:
>
>     INT[1] argv;
>
> >   char sbuf[1024];
> >   io = (IOREQ *)buf;      // Not accepted in dlang
>
> You must use the cast keyword, the pointer to first element of 
> an array is .ptr, and I think you meant sbuf:
>
>     io = cast(IOREQ *)sbuf.ptr;
>
> >   st = write(fd, sbuf, 1024);  //
>
> You can use the .length property of arrays:
>
>     st = write(fd, sbuf, sbuf.length);
>
> Ali



More information about the Digitalmars-d-learn mailing list