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

Anders S via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Nov 29 23:16:38 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 */
>
> 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


Thanks you all guys, and the cast (IOREQ *) ... did the trick!!
I'll have a look at your other comments aswell on struct a.s.o.
/anders




More information about the Digitalmars-d-learn mailing list