save and load a 2d array to a file

Stanislav Blinov stanislav.blinov at gmail.com
Tue Apr 19 09:12:59 UTC 2022


On Tuesday, 19 April 2022 at 06:05:27 UTC, Ali Çehreli wrote:

> One quirk of rawWrite and rawRead is that they want slices of 
> objects. It is a little awkward when there is just one thing to 
> write and read. Uncompiled but something like this:
>
>   int i = 42;
>   file.rawWrite(*cast((int[1]*)(&i)));  // Casted to be an 
> array of 1

Yuck :)

```d
file.rawWrite((&i)[0..1]);
```


More information about the Digitalmars-d-learn mailing list